Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

Datetime2Str usage

(0) ShareShare
ReportReport
Posted on by 1,550

Hi,

If dateTime is month/day/year with time

Why when we use dateTime2Str it becomes day/month...how can we keep it as month/day?

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,962 Most Valuable Professional on at
    RE: Datetime2Str usage

    It's important to realize that datetime values are not stored as string. If your statement "If dateTime is month/day/year with time" suggest that you think it's stored in a specific string format, you're wrong. A format (such month/day/year) applies only when the urcDateTime value gets converted to a string.

    If you don't like the format used by dateTime2Str(), simply use a conversion function that allows you to specify a different format.

  • Suggested answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Datetime2Str usage

    Hi juniorAx,

    Hope the below blog from Martin Drab will help you.

    As per below blog make use of system.time to convert to specified format.

    dev.goshoom.net/.../

    Thanks,

    Girish S.

  • Suggested answer
    Alireza Eshaghzadeh Profile Picture
    Alireza Eshaghzadeh 13,564 Super User 2025 Season 1 on at
    RE: Datetime2Str usage

    Hi junior AX,

    Please check your user option preferences and language for Date, time, and number format. If it is already setup while date format is not as you expected, you can define format of datetime in your code (e.g. DATEFORMAT(dateTime2Str,"yyyy-MM-ddTHH:mm:ss")

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

Announcing Our 2025 Season 1 Super Users!

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

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,160 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans