AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
DAX
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 06.05.2014, 01:16   #1  
Blog bot is offline
Blog bot
Участник
 
25,491 / 846 (79) +++++++
Регистрация: 28.10.2006
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)));
}
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:



X++:
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:
Info Message (11:01:28 pm) getSystemDateTime = 5/1/2014 12:00:00 am
Info Message (11:01:28 pm) utcNow = 5/5/2014 09:01:28 pm
If the system date time is not fixed, it will return the local system datetime, pretty much like utcnow.


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.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
fed: Net requirements update in MRP Module and Working Set of MRP Blog bot DAX Blogs 14 08.05.2012 13:09
Kashperuk Ivan: Tutorial: Determine if a string is a valid UtcDateTime Blog bot DAX Blogs 0 24.02.2012 01:11
Kashperuk Ivan: UtcDateTime in Dynamics AX 2009 Blog bot DAX Blogs 0 17.02.2010 15:05
Kashperuk Ivan: Run AX as a different user from Windows Explorer Blog bot DAX Blogs 0 15.01.2010 02:09
Kashperuk Ivan: Running a class from AOT or "How to assign a class to an action menu item?" Blog bot DAX Blogs 0 22.10.2009 20:05

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 23:28.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.