LAMBDA · Date and time
Age in years, months, and days LAMBDA
xl.age.ymd returns completed years, months, and days. Someone born March 15, 1990 is 36 years, 7 months, and 27 days old on November 11, 2026.
Syntax =xl.age.ymd(birth, on_date)
=LAMBDA(birth, on_date,
LET(
years, DATEDIF(birth, on_date, "Y"),
months, DATEDIF(birth, on_date, "YM"),
days, DATEDIF(birth, on_date, "MD"),
HSTACK(years, months, days)
)
)Arguments
| Name | Required | What to pass |
|---|---|---|
| birth | Required | The start date, usually a birth date. |
| on_date | Required | The later date. It must be on or after birth. |
Examples
Age on November 11, 2026
=xl.age.ymd(DATE(1990,3,15), DATE(2026,11,11))Result 36 years, 7 months, 27 days
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Born | 3/15/1990 | ||
| 2 | As of | 11/11/2026 | ||
| 3 | Years | 36 | 7 | 27 |
xl.age.ymd spills three numbers: completed years, the leftover months, and the leftover days. On November 11, 2026, a birth date of March 15, 1990 is 36 years, 7 months, and 27 days. The 36 counts only birthdays that have already happened. The 7 months run from March 15 to October 15. The 27 days run from October 15 to November 11.
DATEDIF does this and Excel hides it in the function list. The LAMBDA names the three units so a sheet does not have to remember Y, YM, and MD.
Add it to the workbook
Copy the formula in the block above, including the line breaks. Choose Formulas, Name Manager, New. Set the name to xl.age.ymd, the scope to Workbook, and paste into Refers to. Excel Labs can do the same step: open the Advanced Formula Environment, add that name, and save it back to the workbook. A cell then calls =xl.age.ymd(...).
The name needs Microsoft 365, Excel 2024, or Excel for the web. Excel 2021 returns #NAME? for LAMBDA even when it already has XLOOKUP, FILTER, or LET.
How it works
DATEDIF with "Y" is the completed years. "YM" is the completed months after those years are removed. "MD" is the completed days after those months are removed. HSTACK puts the three numbers in a row. For this pair the results are 36, 7, and 27.
Limits
The "MD" unit has long-standing edge cases when the day of the month does not exist in the previous month, especially around the 31st. This example uses the 15th, which exists in every month, so the 27 is solid. For a day count you can check by hand, prefer DAYS. Do not use "MD" as the only age figure on a legal document without checking the calendar.