Question: How can I calculate the actual number of months between two dates?

When I calculate the difference between two dates with the same day using the DateDifference Calendar function, I don't get an integer number of months, but results with extra days, hours, minutes, seconds and milliseconds. How can I calulate the actual number of months?

I appreciate any help.

restart

with(Calendar)

d1 := Date(2024, 1, 5, 0, 0, 0)

_m4674925856

(1)

d2 := Date(2024, 5, 5, 0, 0, 0)

_m4881744064

(2)

DateDifference(d1, d2, 'units' = 'mixed')

4*Units:-Unit(mo)+2*Units:-Unit(d)+20*Units:-Unit(h)+3*Units:-Unit(min)+48*Units:-Unit(s)+800*Units:-Unit(ms)

(3)

NULL

NULL

 

NULL

Download DateDifference.mw

Please Wait...