Dynamics AX – All about dates and X++

by | Jun 17, 2014 | 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.

 

0 Comments

Submit a Comment

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

Upcoming Events

february

27feb11:00 am12:00 pmConfab With Stoneridge - Livestream - Cool Features in Dynamics 365 Business Central

march

04mar12:00 pm12:30 pmPower BI & Reporting with Dynamics 365 Customer Engagement

04mar2:00 pm3:00 pmHow to Incorporate the Power Platform with Dynamics 365 Finance and Supply Chain Management

12mar11:00 am12:00 pmConfab With Stoneridge - Livestream - Power Apps AI Builder

18mar12:00 pm1:00 pmMoving from CRM On Prem to the Cloud – Is it worth It?

18mar2:00 pm3:00 pmThe Past, Present, and Future of Dynamics 365 with Machine Learning and Artificial Intelligence

25mar2:00 pm3:00 pmAchieve Total Data Access & Future-Proof Your Reporting

26mar11:00 am12:00 pmConfab With Stoneridge - Livestream - Portals

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