Dynamics ax 2012 Date and Time Problem ?

Hi to all,

Currently i have met with one problem for displaying date time in batch program. what is the correct way to get current system date and time? Because there is lot of functions are there to display the date and time. And My batch Program is displaying previous date not today date…It affects all the records… The below code i have used

_SCOBIntfTxnStatus.IntfDateIns= DateTimeUtil::date(DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::getSystemDateTime(),


now i got panic … Is there any idea to solve…Plz help me…

Thanks in advance…

Hi parthiban,


This will work.

Thanks for sharing your knowledge.

What do you mean by “my batch program is displaying previous date”? What I see is that you’re saving a date to database and that should be time in UNC. The date will be different that what currently is in some timezones.

Users’ timezone will be applied when displaying dates in forms. If you process displaying by yourself, you have to convert the UTC value to the timezone of the particular user. Don’t forget that users in different timezones may see different date/time for a single UTC value.

Therefore either you don’t save UTC value to database, or you don’t correctly convert it to user’s timezone for display. Is the saved value in UTC?

Hi parimal,

thank you for your reply,

But the problem is,

This code is worked currectly in the past…But today it went wrong. when i used this code in batch it tooks the past date…Is there any separate functions for batch program to get current system date and time ?..

Thanks in advance…

Hi Martin,

Thank you for your reply,

I have found solution for my problem.

Actually Problem is not there martin.

In my dynamics ax 2012 work-space i have set the session date time. And i applied 2 functions. one is today(); another one is systemdateget(). In this two, today() is took system date time. And the Systemdateget() took session date and time what i am exactly setted in the workspace. So this is the Correct way or any other functions to take only System date ?

What’s the correct way depends on what you actually want to get. I can’t tell you whether your logic should support session date, for instance.

Also look at DateTimeUtil::getSystemDateTime() and DateTimeUtil::utcNow().