Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

How to convert UTC into DateTime format

(0) ShareShare
ReportReport
Posted on by 2,953

Hi All

I want to add a number of minutes(hrs) to UTC and then extract the time part. Since UTC is converted to text, I cannot use DT2Time function.

here's what I have tried:

get date time as string

UTC := format(CurrentDateTime,0,9)
UTCText2 := Format(CurrentDateTime+ (MyMinutes*60000)),0,9);//add minutes to UTC
 
Now I'm stuck trying to extract Time part as DT2Time doesn't work on a string. Is there a way to get the UTC as a DateTime value or convert string to datetime?
  • Suggested answer
    Nitin Verma Profile Picture
    21,567 Moderator on at
    RE: How to convert UTC into DateTime format

    If its working then great.

  • Samantha73 Profile Picture
    2,953 on at
    RE: How to convert UTC into DateTime format

    I guess the solution is rather simple

    to convert UTC string to datetime:

    EVALUATE(MyDateTimeVar, UTCtext2)

  • Samantha73 Profile Picture
    2,953 on at
    RE: How to convert UTC into DateTime format

    Thanks but the problem is extracting DateTime or time from UTC as it's text

    format(CurrentDateTime,0,9)

  • Suggested answer
    Nitin Verma Profile Picture
    21,567 Moderator on at
    RE: How to convert UTC into DateTime format

    Hi,

    You can try below

    Hours, Minutes, Seconds and Millisecond are integer.

    Milliseconds := TIME - 000000000T;

    Hours := Milliseconds DIV 1000 DIV 60 DIV 60;

    Milliseconds -= Hours * 1000 * 60 * 60;

    Minutes := Milliseconds DIV 1000 DIV 60;

    Milliseconds -= Minutes * 1000 * 60;

    Seconds := Milliseconds DIV 1000;

    Milliseconds -= Seconds * 1000;

    MESSAGE('%1 %2 %3', Hours, Minutes, Milliseconds);

    Source : forum.mibuso.com/.../how-to-calculate-hour-minutes-and-seconds-from-a-time

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

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2,655

#2
Mansi Soni Profile Picture

Mansi Soni 1,574

#3
YUN ZHU Profile Picture

YUN ZHU 1,453 Super User 2025 Season 1

Featured topics

Product updates

Dynamics 365 release plans