Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

Display Millisecond from time

Posted on by 910
Hi i'm working to get a date in a specific format now i can show for example : 2015-11-09 22:33:06
but i want that 2015-11-09 22:33:06.165

so how can i get Millisecond from time :
static void TimeJob(Args _args) { timeOfDay theTime = timeNow(); ; info( time2Str(theTime, TimeSeparator::Colon, TimeFormat::Hour24) ); }
/**
22:33:06

**/
but i want to get somthing like
22:33:06.164
  • ALAhmed Profile Picture
    ALAhmed 910 on at
    RE: Display Millisecond from time

    i thank it's work

    static void SauUtcDateTime(Args _args)

    {

       utcDateTime             dateTime;

       TimeOfDay               timeNo=timeNow();

       str                     s,dateMillisecond;

       TimeInMS                startTime,endTime;

       startTime               = WinAPI::getTickCount();

       sleep(100);

       endTime                 = WinAPI::getTickCount();

       s = date2Str

           (today(),

           321,

           DateDay::Digits2,

           DateSeparator::Hyphen, // separator1

           DateMonth::Digits2,

           DateSeparator::Hyphen, // separator2

           DateYear::Digits4

           );

       info(strFmt("dateTime == %1 %2.%3 ", s,time2str(timeNo,TimeSeparator::Colon,TimeFormat::Hour24),endTime-startTime));

       dateMillisecond = s+time2str(timeNo,TimeSeparator::Colon,TimeFormat::Hour24)+"."+int2str(endTime-startTime);

       info(strFmt("dateTime == %1 ",dateMillisecond));

    }

  • Verified answer
    Luiz Ventura Profile Picture
    Luiz Ventura 152 on at
    RE: Display Millisecond from time

    Hello, if you'll only display the time, maybe you can use winApi::getTickCount() to get the miliseconds, after that you can join the two pieces of information in a single string.

    Kind regards.

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Display Millisecond from time

    timenow doesn't have milliseconds. It only contains the seconds since midnight. DateTime and UTCDateTime do have the miliseconds you want. I fyou want to time an operation in AX in milliseconds I suggest you look at: WinAPI::getTickCount();

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,989 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,588 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans