Axaptapedia is now maintained by AgileCadence For more information please click here.
UtcDateTime
From Axaptapedia
Since version 2009 Dynamics AX supports different timezones. This feature is implemented in way that a UtcDateTime value is converted to UTC time when stored in database. The conversion is transparent for the user. The value is converted back to local time when it is viewed on form or report.
- Be aware that the table browser does this conversion too! The value in the table browser may NOT be the value in the database.
- Conversion is not applied for X++ code, you have to do this by your own!
Example[edit]
This example is create in Austria at Summertime, thats UTC + 2
22.7.2009:00:00 Austria is 21.7.2009:22:00 in UTC
<xpp> static void Job2(Args _args) {
UtcDateTimeDemo demo; ;
select firstonly demo where demo.RecId == 5637144576; // prompts the value from the table, no conversion here! info(strfmt("%1",demo.UtcField));
// thats the expected value! info(strfmt("%1", DateTimeUtil::applyTimeZoneOffset(demo.UtcField,DateTimeUtil::getClientMachineTimeZone())));
} </xpp>
When you fetch data from the database you have to apply the timezone to get the local value