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

september

02sep10:00 am10:30 amThe Modern Manufacturer - Cycle Count Management

02sep12:00 pm12:30 pmBest Practices for Work Order Planning and Routing for Field Service Companies

09sep10:00 am11:00 amWhat is Levridge? An Overview of the Ultimate Ag Solution

09sep12:00 pm12:30 pmOverview of Microsoft Promotion for NAV and GP Clients

10sep11:00 am12:00 pmConfab with Stoneridge - Livestream - Field Service Comparisons

16sep10:00 am10:30 amThe Modern Manufacturer - Product Lifecycle Management

16sep12:00 pm12:30 pmHow to Upgrade to Dynamics 365 Finance and Operations: Examining Custom Code and ISV Implications

16sep2:00 pm2:30 pmScheduling and Dispatching for the Modern Field Service Company

23sep12:00 pm1:00 pmDynamics 365 Business Central Wave 2 Release Preview - An Overview of the Most Exciting New Features Coming in October

24sep11:00 am12:00 pmConfab with Stoneridge - Livestream - The Modern Workplace: Teams, Sharepoint, Outlook, Office, and AI Integration

30sep10:00 am10:30 amThe Modern Manufacturer - Return Management

30sep12:00 pm12:30 pmEmpowering Your Field Service Technicians with a Mobile Solution

october

07oct12:00 pm1:00 pmThe Three Paths to Business Central from Dynamics GP

08oct11:00 am12:00 pmConfab with Stoneridge - Livestream - The Vision and Strategy of Microsoft Business Systems

14oct10:00 am10:30 amThe Modern Manufacturer - Complex Cost Modeling

14oct12:00 pm12:30 pmGenerating Custom Inspection or Process Forms

19octAll Day22Stoneridge Connect Fall 2020

22oct11:00 am12:00 pmConfab with Stoneridge - Livestream - Stoneridge Connect Recap

28oct10:00 am10:30 amThe Modern Manufacturer - Engineering Change Orders

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