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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Convert format current system date/time value

(0) ShareShare
ReportReport
Posted on by 916

Hi,

I want convert current system date to datetime like this format : yyyymmddhhmmss

i tried this :

// my current system date/time value in UTC
GMTDateTime = DateTimeUtil::getSystemDateTime();
info(strFmt("Datetime in GMT: %1",datetime2str(GMTDateTime)));

the screen show : Datetime in GMT: 5/3/2016 08:00:49 am

i want remove DateSeparator and show it like this : 201634080049

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,805 Most Valuable Professional on at

    It's not about converting to datetime, it's about converting datatime to string in a specific format.

    You could do it in pure X++, nevertheless custom formatting string in .NET makes it really easy, therefore I would prefer code like this (using .NET Interop):

    System.DateTime dateTime = System.DateTime::get_UtcNow();
    str utcTimeAsStr = dateTime.ToString('yyyyMdHHmmss');
        
    info(strFmt("Datetime in GMT: %1",utcTimeAsStr));
  • ALAhmed Profile Picture
    916 on at

    Thanks Martin

  • pattan ismail Profile Picture
    20 on at

    Try this 

    System.DateTime dateTime = System.DateTime::get_UtcNow();
    str utcTimeAsStr = dateTime.ToString('ddMMyyHHmmss');
    info(strFmt("Datetime in GMT: %1",utcTimeAsStr));

  • pattan ismail Profile Picture
    20 on at

    thanks,Its really helpful

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
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans