Skip to main content

When using the StringToMoment function to calculate the number of hours between two dates and running into something weird:

 

As you can see AIMMS tells me 0 minutes elapsed between 10:00:00 and 11:00:00

 

My guess is that somehow AIMMS is assuming the referencedate as UTC time, while it assumes the second date as my local timezone.

I have also tried to use 

StringToMoment("%c%y-%m-%d %H:%M:%S %TZ", "minute], "2023-10-11 10:00:00" , "2023-10-11 11:00:00 UTC")

To indicate I really want to have the second timestamp as UTC, but that did not help.

 

What is the small/obvious thing I am overlooking here?

@gdiepen 

Maybe set this option that has helped me at times: use_UTC_forCaseAndStartEndDate

 


@MarcelRoelofs That is helping….

 

When I just checked in my project that was created a couple of days ago, this option was set to the non-default value “On”. After switching this option back to the default value “off” then everything was working as expected.

 

In the help it is mentioned that the default is different for new projects vs existing projects, but does not make it super clear.

 

Happpy that I do have a fix now, but a bit surprised the defaults in a new project do not lead to expected results without modifying some project settings


yeah, we went meticulously through a lot of things when introducing multi-time zone support in WebUI, but both for time zone support and character encodings the same thing is true: it is made easy to do wrong, and hard to do right. 


Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator