06.05.2014, 01:16 | #1 |
Участник
|
Kashperuk Ivan: Q&A session: Working with UtcDateTime from X++
Источник: http://kashperuk.blogspot.com/2014/0...time-from.html
============== There were a couple questions asked in the post I wrote a while back about the use of UtcDateTime in AX. 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. X++: 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))); } Date converted to DateTime, with 0 for time and no timezone offset = 3/5/2014 12:00:00 amQuestion 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: X++: static void DifferenceBetweenUtcNowAndSystem(Args _args) { info(strFmt("getSystemDateTime = %1", DateTimeUtil::getSystemDateTime())); info(strFmt("utcNow = %1", DateTimeUtil::utcNow())); } 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 Note, that msdn actually also describes a slight difference in how utcnow works - it seems it always runs on the server, so always returns the AOS datetime. I can't test it right now because only have a dev.setup with everything on 1 box. Once I get a 3box one, I will update this post with a confirmation. Источник: http://kashperuk.blogspot.com/2014/0...time-from.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. Последний раз редактировалось mazzy; 07.05.2014 в 10:41. |
|
|
|