Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

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 :)

*This post is locked for comments

  • 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 230,188 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 230,188 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?

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!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans