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

Announcements

News and Announcements icon
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 3,328

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?
I have the same question (0)
  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    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

  • Samantha73 Profile Picture
    3,328 on at

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

    format(CurrentDateTime,0,9)

  • Samantha73 Profile Picture
    3,328 on at

    I guess the solution is rather simple

    to convert UTC string to datetime:

    EVALUATE(MyDateTimeVar, UTCtext2)

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    If its working then great.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 695 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 422 Super User 2026 Season 1

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 328 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans