Wednesday, October 19, 2011

Working with dates in Dynamics AX

Axapta x++ code to work with dates. Exists others ways to do that (DateTimeUtil), but I think this is the easiest way to work with dates.


Add days to a date:
systemdateget() + 5; //Add 5 days to a date


Add months to a date (we use a Global class function):
dateMthFwd(systemdateget(), 3); //Add 3 months to a date


Add years to a date (we use the same function than the add months to a date, because there isn't a specific function to add years in the Global class):
dateMthFwd(systemdateget(), 24); //Add 2 years to a date

No comments:

Post a Comment