Microsoft Dynamics AX 2012:DateTimeUtil and HcmDateTimeUtil functions in Ax 2012

Hi,

  • DateTimeUtil::getSystemDateTime(): Gets Date and Time value of the system in GMT

Ex:  if the system user has the TimeZone ‘UTC +5’  and the current date time is 6/20/2013 5:00PM then the method will return ‘6/20/2013 12:00PM’

  • DateTimeUtil::utcNow(): Gets the Date and Time value in GMT/UTC

Ex. if the system user has the TimeZone ‘UTC +5’  and the current date time is 6/20/2013 5:00PM then the method will return ‘6/20/2013 12:00PM’.(this is similar to getSystemDateTime() but it gets the date and time value of the server.

  • HcmDateTimeUti::startofCompanyDay(): This method takes an input parameter of utcDateTime, and returns the date and time value that represent the starting of the given date after applying the companyTimeZone.

 

Ex.if the value passed in the parameter is ‘6/20/2013 10:00 PM’ then it will return ‘6/20/2013 12:00:00 AM’ after applying the companyTimeZone

  • HcmDateTimeUti::startofCurrentDay(): This method returns the date and time value that represent the starting of the current  day after applying the userPreferredTimeZone.

 

Ex.if the value passed in the parameter is ‘6/20/2013 10:00 PM’ then it will return ‘6/20/2013 12:00:00 AM’ after applying the userPreferredTimeZone

  • DateTimeUtil::applyTimeZoneOffset(): This method is used to applyTimeZone to the specific dateTime value.

Ex.If I have a date and time value in GMT like ‘6/20/2013’ 12:00:00 PM’ I have a time zone

‘‘UTC +5’ then after applying TimeZone like

dateTime = 6/20/2013 12:00:00 PM

DateTimeUtil::applyTimeZoneOffset(dateTime, DateTimeUtil::getUserPreferredTimeZone())

will return 6/20/2013 5:00:00 PM

  •  DateTimeUtil::removeTimeZoneOffset(): This method is used to removeTimeZone to the specific dateTime value.

Ex.If I have a date and time value in GMT like ‘6/20/2013’ 12:00:00 PM’ I have a time zone

‘‘UTC +5’ then after removing TimeZone like

dateTime = 6/20/2013 12:00:00 PM

DateTimeUtil::removeTimeZoneOffset(dateTime, DateTimeUtil::getUserPreferredTimeZone())

will return 6/20/2013 7:00:00 A.M

Screen1

Important about UtcDateTime table field.

 Based on above screen shot we need to understand one thing is whenever the utcDateTime value in inserted in the utcDateTime field of the buffer, offset is applied automatically.Similiary when the value is retrieved from the field of the buffer ,offset is removed automatically.

Like: (Time Zone is ‘UTC +5’)

Screen2

But since offset will be applied automatically on inserting in the table so the values in table are

Screen3

Please let me know for any queries.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s