Monthly Archives: February 2020

Tip #66 | UTC Calculation

I have not blogged as much as I want to recently. Not because there is nothing to write about, but because I am so insanely busy.

However, today I ran into a question that required first Google and then Statical Prism to solve.

UTC Calculation in Dynamics NAV (Or Business Central)

This used to be cumbersome and required dirty tricks. Alternatively (and this is how I managed to solve it until today) you can setup a UTC service tier.

But, with the help of Prism I found that Codeunit 358 now has this code

[External] ConvertToUtcDateTime(LocalDateTime : DateTime) : DateTime
IF LocalDateTime = CREATEDATETIME(0D,0T) THEN
  EXIT(CREATEDATETIME(0D,0T));
DotNetDateTimeOffset := DotNetDateTimeOffset.DateTimeOffset(LocalDateTime);
DotNetDateTimeOffsetNow := DotNetDateTimeOffset.Now;
EXIT(DotNetDateTimeOffset.LocalDateTime - DotNetDateTimeOffsetNow.Offset);

So no more stupid workarounds, just use this instead.

Please hold on for more stuff on my blog. I recently converted one of my customers to SQL Azure with Windows Virtual Desktop, Azure Logic Apps, Blob storage & Azure Functions. So much to blog about. #ServerlessComputing

I’m also starting on a new contract next week that will help me multiply my skills in an efficient way. Very enthousiastic to try that out for the first time.

So hang on and keep coding….