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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 07.03.2009, 06:12   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
Dynamics AX: Today to Julian Date value inside Dynamics AX, X++
Источник: http://dynamics-ax.blogspot.com/2009...ue-inside.html
==============
I hope everyone is having a great Friday evening, and is ready for the weekend. In light of it being Friday, thought I would share something, maybe some of you already know.

In a project I am working on, one of the needs is to have Julian Date values for specific Date's. This is for an integration project, and the integrating software to Dynamics AX is expecting this value. There can be some possible hang ups if the 0 value date is different, but that's is not anything I can help. (Unless I create a custom Julian function that has the same Zero based starting point.)

Anyway I thought for sure there would be an X++ built in function or WinAPI call. I did not find one, so I turned to the next level in such things, .Net.

The following is code example of taking Today() method value and turning it into a Julian Date value representation:


System.DateTime CurrDT;
int64 jd;
;

CurrDT = new System.DateTime(Year(Today()),
mthofyr(Today()),
dayofmth(Today()));

jd = CurrDT.ToOADate();
info(strfmt("Today is: %1 and Julian Value is: %2",Today(),jd));


So what I do is take and create an instance of the .Net System.DateTime class. Then set it on the new / constructor call to be today's Year, Month, Day. Then I take and call the method off of that DateTime object, ToOADate(). I set this to an internal Int64 variable, and then call an info() to show the difference between the standard date value and the Julian date value.

You can learn more about the ToOADate() method call by going to it's MSDN article stub found here: DateTime.ToOADate - MSDN Home


This is from the MSDN stub for the DateTime.ToOADate method:
"An OLE Automation date is implemented as a floating-point number whose value is the number of days from midnight, 30 December 1899. For example, midnight, 31 December 1899 is represented by 1.0; 6 A.M., 1 January 1900 is represented by 2.25; midnight, 29 December 1899 is represented by -1.0; and 6 A.M., 29 December 1899 is represented by -1.25."

So on any windows based system, you should be ok, because 99% should use the same basis for a julian date value. However you might have to work with this value or create your own custom julian date function if the zero data basis for the system your integrating with is different that the 'midnight, 30 December 1899' value that the .Net DateTime.ToOADate() method call uses.

Now, honestly, that more than I thought I would ever learn about a Julian Date value. I hope this helps someone out, and if there is another way, I am all ears, leave a comment and I will update this post to reflect such options.

Check back soon, Convergence is next week and there will be all kinds of great post from it. Also I plan on really taking the interview with Lachlan Cash and expanding on it. A lot of great things came out of that interview that need explaining and more detail. See you next time, and have a great weekend!


"Visit the Dynamics AX Community Page today!"




==============
Источник: http://dynamics-ax.blogspot.com/2009...ue-inside.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
axStart: Microsoft Dynamics AX 2009 Hot Topics Web Seminar Series Blog bot DAX Blogs 0 06.08.2008 12:05
Inside Dynamics AX 4.0: The Security Framework Blog bot DAX Blogs 0 31.10.2007 11:40
Inside Dynamics AX 4.0: Working with the .NET Business Connector Blog bot DAX Blogs 0 04.10.2007 05:15
Inside Dynamics AX 4.0: Usage Scenarios Blog bot DAX Blogs 0 04.10.2007 05:15
Inside Dynamics AX 4.0: Inside the Business Connector Blog bot DAX Blogs 0 04.10.2007 05:15

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

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

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