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 :
Small and medium business | Business Central, N...
Answered

How to convert UTC into DateTime format

(0) ShareShare
ReportReport
Posted on by 3,247

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,708 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,247 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,247 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,708 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

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,151

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,443 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,092 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans