Dynamics AX – All about dates and X++

by | Updated August 30, 2016 | Development, Dynamics AX

Well, we have all been there… you are working with dates in Dynamics AX and you realize there are tons of functions out there for dates… which one to pick?  And actually almost all the time I cannot find what I need.

So, I am just going to write out everything I can recall about date functions at this point and we will go from there.

  • I will start with the Current Business Date.
    Generally, I have used systemDateGet() which holds the logic business date of the system. There is one more function called today() which gives the actual machine date. So far I haven’t felt the need to use today() but if anyone needs, it is out there.
    systemDateGet()
    today()There is one global method called getSystemDateTime(); which sets the current UTC time as a utcdatetime type. Only DateTimeUtil::getSystemDateTimecompensates for the time zone of the user, so as a best practice we should use this one instead of systemDateGet()

 

  • There are functions out there which will allow you to get Day of Month, Month of Year, and so on.

 

  • When we need to get the next month, next year or may be next quarter, We have:

 

  • Creating your own date
    mkdate : Creates a date based on three integers, which indicate the day, month, and year, respectively.
    e.g. mkDate(09, 09, 1989);

 

  • Date to String conversion
    date2str(systemdateget(), 123, dateDay::Digits2, DateSeparator::Space, DateMonth::Digits2, DateSeparator::Space, DateYear::Digits4);There is one more method available in case we want to use the regional settings of the user.
    date2strUsr(systemdateget());
  • UTCDateTime conversion
    Just so that you know, values of type UTCDateTime are stored in the database in UTC time zone while in the User Interface UTCDateTime values are displayed in  a user preferred time zone.  And the regular Date and Time values are not related to any time zone, so both stored and displayed values are equal.

 


 

For more on working with dates in Dynamics AX check out these blog posts: Working With UTC Date Time Functionality and Working With UTC Date Time Fields in Select Statements.

 

Related Posts

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Upcoming Events

december

02dec9:00 am12:00 pmOnline Workshop - Dynamics GP Year End Close (Morning Session)

03dec11:00 am12:00 pmConfab with Stoneridge - Livestream: Live Agents, Power Virtual Agents, Omnichannel – Oh My!

03dec1:00 pm4:00 pmOnline Workshop - Dynamics GP Year End Close (Afternoon Session)

09dec10:00 am10:30 amThe Modern Manufacturer - Manufacturing Policy Management

17dec11:00 am12:00 pmConfab with Stoneridge - Livestream - Technology in 2020: A Year in Review

january

06jan10:00 am10:30 amThe Modern Manufacturer - MRP v MPS – What, When and How

14jan11:00 am12:00 pmConfab with Stoneridge - Livestream - Looking Forward: Predictions for Technology in 2021

20jan10:00 am10:30 amThe Modern Manufacturer - Demand Forecasting Functionality

About Stoneridge
Stoneridge Software is a unique Microsoft Gold Partner, with emphasis on partner. With specialties in Microsoft Dynamics 365, Microsoft Dynamics AX, Microsoft Dynamics NAV, Microsoft Dynamics GP and Microsoft Dynamics CRM, we focus on attracting the most knowledgeable experts in the field to our team, and prioritize delivering stellar solutions with maximum impact for your business. At Stoneridge, we are deeply committed to your results. Each engagement is met with a dedicated team, ready to provide thorough, tailored, and expert service. Based in Minnesota, we intentionally “step into your shoes,” wherever you are. We focus on what you care about, and develop trusting, long-term relationships with our clients.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!

X