web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

format date

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at
    Re: format date

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

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

  • Community Member Profile Picture
    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 :)

  • Luegisdorf Profile Picture
    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
    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 3

#3
Scott_itD Profile Picture

Scott_itD 2 Community Manager

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans