Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

format date

Posted on by Microsoft Employee

Hello.

I am using report.

In each field of the report there is datamethod.

I couldn't find something better, but I overrided on  the datamethod, and put them a code that convert date to string.

the method I choose is strfmt, but I didn't find a way to convert to a specific format :

i.e dd/mm/yyyy.

 

How can I convert data field (of a table in database) to string with a specific format?

 

Thanks :)

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    Re: format date

    Most of the parameters are enumerations.  Try leaving most at auto and see if the format meets with your approval.  For example:

    strDate = date2str(thisDate, 321, DateDay::Auto, DateSeparator::Auto, DateMonth::Auto, DateSeparator::Auto, DateYear::Auto);

    The sequence should indicate which parts of the date should be in which order, with 1 = days, 2 = months, and 3 = years.  Some examples

    123 = day / month / year

    213 = month / day / year

    321 = year / month / day

    132 = year / day / month

    etc.

    EDIT: ah, beaten to the punch.  Patrick is right though.

  • Luegisdorf Profile Picture
    Luegisdorf 1,930 on at
    Re: format date

    123 equal day-month-year

    321 equals year-month-day

    Means:

    1 for day

    2 for month

    3 for year

    I suggest you use it that way:

    date2str(date, 123, 2, 4, 2, 4, 2);

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    Re: format date

    What is the parameter : "Day". and where can I find information for the value, I should give (i.e : 321, for the link you gave) ?

    Thanks :)

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    Re: format date

    Try using the built-in function date2str() method.

    msdn.microsoft.com/.../aa857241.aspx

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,219 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,056 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans