AgeM, AgeY, and AgeYM share the same syntax:
·
AgeYM returns
age (i.e. elapsed time) in complete years and months based on two dates (e.g., a birth date and a valuation date), where AgeYM = AgeY + AgeM /12.
·
AgeY returns
the years portion of the AgeYM function as a whole number.
·
AgeM returns
the months portion of the AgeYM function as a whole number.
The
calculation is performed as follows:
Function AgeYM(Date1, Date2) m1 = Month(Date1): d1 = Day(Date1): y1 = Year(Date1) m2 = Month(Date2): d2 = Day(Date2): y2 = Year(Date2) LastDay = DaysInMonth(m2, y2) AgeYM = (y2 - y1) + (m2 - m1) / 12 If (d2 < d1) And (d2 < LastDay) Then AgeYM = AgeYM – (1 / 12) End Function |
Syntax
AgeM
(Date1, Date2)
AgeY
(Date1, Date2)
AgeYM (Date1, Date2)
Parameter Name |
Description |
Date1 |
The
first date. Note that the order of the dates does not matter – the function
returns the date difference from the earlier date to the later date. |
Date2 |
The
second date. |
Note
A comparison of various date calculation functions is shown below:
Related Topics