21 August 2012

Difference between two dates in days

To get the difference between two dates in dynamics ax just convert the dates into numbers and subtract one from the other. The result would be the amount of days between these dates.

days = date2num(Date123) - date2num(Date234);

To get the difference between two DateTime Values just use the DateTimeUtil Class. The result is the difference in seconds. So just divide these through #secondsPerDay and you'll get the days


days = DateTimeutil::getDifference(DateTime123, DateTime234) / #secondsPerDay;
Post a Comment