Question 1:
Hi. how can put date in a field utcdatetime?Answer:
The method newDateTime from class DateTimeUtil can be used to accomplish this, as it takes the date and time parts in separately as arguments, followed by the TimeZone enumeration in case a timezone offset needs to be factored in. Otherwise the UTC timezone will be used.
static void CreateUtcDateTimeFromDate(Args _args) { date locDate = mkDate(5, 3, 2014); info(strFmt("Date converted to DateTime, with 0 for time and no timezone offset = %1", DateTimeUtil::newDateTime(locDate, 0))); }
The result of executing this job would look like below:
Date converted to DateTime, with 0 for time and no timezone offset = 3/5/2014 12:00:00 am
Question 2:
Hi...Can you please tell the difference between UtcNow() and getSystemDateTime(). Both are returning GMT time only. But where as in msdn they described differently...Answer:
The difference is you can "fix" the systemDateTime either through the API (DateTimeUtil::setSystemDateTime()) or through the Tools in the Dynamics menu, as shown on the screenshot:
Session date and time dialog |
static void DifferenceBetweenUtcNowAndSystem(Args _args) { info(strFmt("getSystemDateTime = %1", DateTimeUtil::getSystemDateTime())); info(strFmt("utcNow = %1", DateTimeUtil::utcNow())); }
So, after having fixed the system datetime, the output from executing this job would be like below:
If the system date time is not fixed, it will return the local system datetime, pretty much like utcnow.Info Message (11:01:28 pm) getSystemDateTime = 5/1/2014 12:00:00 amInfo Message (11:01:28 pm) utcNow = 5/5/2014 09:01:28 pm
No comments:
Post a Comment
Please don't forget to leave your contact details if you expect a reply from me. Thank you