Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

get current date format of user

Posted on by Microsoft Employee

How can I get the current day format of the current user (whether is dd/mm/yy or yy/mm/dd etc.)?

Thanks :)

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: get current date format of user

    you can use this method

    display str FinalTXT()

    {

    return   'From:  ' + dayname(dayofwk(fromdate)) + ' ' + date2str(fromdate,123,DateDay::Digits2,DateSeparator::slash,DateMonth::Digits2,

                  DateSeparator::slash, DateYear::Digits4) + '  To:   ' + dayname(dayofwk(todate)) + ' '

         + date2Str(todate,123,DateDay::Digits2,DateSeparator::slash,DateMonth::Digits2,

                  DateSeparator::slash, DateYear::Digits4) + '   Time:  '  + time2Str(timenow(), TimeSeparator::Colon, TimeFormat::AMPM) ;

    }

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 228,177 Most Valuable Professional on at
    RE: get current date format of user

    Try this:

    System.Globalization.DateTimeFormatInfo formatInfo = System.Globalization.DateTimeFormatInfo::get_CurrentInfo();
    str shortDatePatten = formatInfo.get_ShortDatePattern();
  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: get current date format of user

    Yes.

  • Martin Dráb Profile Picture
    Martin Dráb 228,177 Most Valuable Professional on at
    RE: get current date format of user

    Do you mean the short date format set up in Windows on user's client machine?

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,339 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,177 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans