About EasyMorph Tutorials & Examples Web-help

Agemonths function returns absolute value

The agemonths function returns the absolute value of number of months. Example agemonths(#3/1/2021, #1/1/2021) returns 2 instead of -2. The same behavior if subtracting dates: 3/1/2021 - 1/1/2021 returns 59 instead of -59. Is this the intended behavior. If so, is there an alternative function I should be using?

This behavior is by design. If you need to get a relative age, use an expression such as below:

LET age = agemonths([Date1], [Date2])
IF [Date1] > [Date2] THEN -age ELSE age
To learn more about EasyMorph visit easymorph.com.