convert date format mm/dd/yy to dd/mm/yy

upasanisandipupasanisandip Member Posts: 405
hi
How can I convert date from mm/dd/yy format to dd/mm/yy
I need it in one codeunit

thanks

Comments

  • remco_rauschremco_rausch Member Posts: 68
    What do you need it for? Are you importing in one format and want to save it in another format?

    The FORMAT function might be of help to you.
  • gulamdastagirgulamdastagir Member Posts: 411
    try this:
    d := TODAY;
    month:=DATE2DMY(d,2);
    day:=DATE2DMY(d,1);
    year:=DATE2DMY(d,3);
    DateText:=FORMAT(month)+'/'+Format(day)+'/'+Format(year);
    Regards,

    GD
  • DenSterDenSter Member Posts: 8,307
    Nah, the format function is much easier. Assuming the date is in a date type variable/field, you can do:
    MESSAGE(FORMAT(MyDate,0,'<day,2>/<month,2>/<year4>'));
    
  • mukshamuksha Member Posts: 274
    Hi,
    Please go to the report section and set the SourceExpr. in the properties of date format to FORMAT(TODAY,0,3) or FORMAT(TODAY,0,4). You will get the desired result.
    Mukesh Sharma
  • gulamdastagirgulamdastagir Member Posts: 411
    FORMAT is for experts ,Example from C/SIDE Reference Guide is also wrong

    Example
    This example shows how to use the FORMAT function.

    MESSAGE(Text000, FORMAT(-123456.78, 15, 3));

    Create the following text constant in the C/AL Globals window:

    Text Constant
    ENU Value

    Text000
    'The formatted value: >%1<'


    The message window shows:

    The formatted value: > 123,456.78 [-X
    Regards,

    GD
  • DenSterDenSter Member Posts: 8,307
    And what exactly is your point? FORMAT is just another keyword in C/AL code, you just have to learn how to use it. It sure is easier to program one line of code as opposed to the 5 line snippet for which you have to create additional variables.
Sign In or Register to comment.