Dynamics AX In-Market Engineering

Dynamics AX In-Market Engineering (Sustained Engineering)

Date\time data reflected in User's preferred time zone after conversion from UTC

Date\time data reflected in User's preferred time zone after conversion from UTC

  • Comments 1
  • Likes

Scenario

When running reports that contain date\time information that is stored in the database in UTC format the reports are showing the user's preferred time zone instead of the company's specified time zone.

Resolution

To display the timezone information in the company timezone instead of the user's perferred time zone, you can change the setText method (Example from \Reports\HRMCourseAttendeeStatusList):

From:

void setText()
{
    periode.text(strfmt("@SYS53184", date2StrUsr(DateTimeUtil::date(hrmCourseTable.StartDateTime), DateFlags::FormatAll),
                                    date2StrUsr(DateTimeUtil::date(hrmCourseTable.EndDateTime), DateFlags::FormatAll)));

}

To:
...                                    
    periode.text(strfmt("@SYS53184", date2StrUsr(DateTimeUtil::date (DateTimeUtil::applyTimeZoneOffset(hrmCourseTable.StartDateTime, DateTimeUtil::getUserPreferredTimeZone())), DateFlags::FormatAll),
    date2StrUsr(DateTimeUtil::date (DateTimeUtil::applyTimeZoneOffset(hrmCourseTable.endDateTime, DateTimeUtil::getUserPreferredTimeZone())), DateFlags::FormatAll)));
...                                   
}

Comments
  • Not sure I understand this correctly but shouldn't it say DateTimeUtil::getCompanyTimeZone() instead of DateTimeUtil:getUserPreferredTimeZone() if you want the company timezone?

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment