Cellwise Start free

Excel guide · 6 min read

How to calculate age in years and months in Excel

Quick answerPut the as-of date in a cell (H1 here) and use =DATEDIF(B2,$H$1,"y")&" years, "&DATEDIF(B2,$H$1,"ym")&" months", where B2 is the date of birth. "y" counts complete years and "ym" the months left over after them. For days as well, skip DATEDIF's "md" unit, which Microsoft warns can be wrong, and use =$H$1-EDATE(B2,DATEDIF(B2,$H$1,"m")).

Sample data

Every result on this page was calculated from this sheet by the same spreadsheet engine the Cellwise app uses.

ABCDEFGH
1NameDate of birthAs ofNov 3, 2026
2Maya ChenMar 14, 1992
3Leo AlvarezNov 4, 2019
4Priya NairNov 3, 1985
5Tom BeckerJan 31, 2000
6Zoe ParkFeb 29, 2008
7Sam OkaforJan 20, 2026
8Grace LinDec 25, 1958

Download this sheet as an Excel practice file (.xlsx)

Years and months with DATEDIF

DATEDIF(start, end, unit) measures the gap between two dates. With "y" it returns complete years, so the age only goes up once the birthday has passed. With "ym" it returns the complete months left after those years, always 0 to 11. Join the two with & and some text and you have the label.

The as-of date sits in H1 (3 November 2026) and is locked with dollar signs so the formula fills down. Maya Chen was born on 14 March 1992. She turned 34 in March, and her 14 October "month birthday" has passed but 14 November hasn't, so she is 34 years and 7 months.

DATEDIF is a hidden function: Excel doesn't suggest it as you type and shows no argument tooltip, but it works in every current version. Type it in full.

=DATEDIF(B2,$H$1,"y")&" years, "&DATEDIF(B2,$H$1,"ym")&" months"

Result: 34 years, 7 months

"34 years, 7 months" for Maya Chen.

A label that reads naturally

The basic formula gives "41 years, 0 months" for Priya Nair, whose birthday is today, and "0 years, 9 months" for Sam Okafor, born in January. For name badges, letters or a class list, you usually want "41 years" and "9 months", plus "1 year" rather than "1 years".

LET names the years and months once, so DATEDIF runs twice instead of in every IF. Each part is added only when it is needed, and a comma goes between them only when both are there. A baby under one month old still gets "0 months", so the cell is never blank.

=LET(y,DATEDIF(B7,$H$1,"y"),m,DATEDIF(B7,$H$1,"ym"),IF(y=0,"",y&IF(y=1," year"," years"))&IF(AND(y>0,m>0),", ","")&IF(AND(y>0,m=0),"",m&IF(m=1," month"," months")))

Result: 9 months

"9 months" for Sam Okafor, born 20 January 2026. The same formula gives "41 years" for Priya and "34 years, 7 months" for Maya.

Why not use "md" for the days

DATEDIF has an "md" unit for the days left over after complete months, and it is the obvious way to get "years, months, days". Microsoft's own DATEDIF page recommends against it, because it can return a negative number, a zero or an inaccurate result. The problem shows up when the birthday falls on a day the previous month doesn't have, such as the 29th to 31st.

Tom Becker was born on 31 January 2000. On 1 March 2026 he had just passed his 26th birthday plus one month (February has no 31st, so his month birthday fell on 28 February). His real answer that day is 26 years, 1 month, 1 day, but "md" returns a negative number. On most dates "md" gives the right answer, which is exactly why the bug slips into finished reports.

=DATEDIF(B5,DATE(2026,3,1),"md")

Result: -2

-2 days for Tom on 1 March 2026, an impossible age.

Days the safe way: EDATE

Count the complete months with DATEDIF "m", jump forward that many months from the birth date with EDATE, and subtract that date from the as-of date. What is left is the number of days since the last month birthday, and it can never be negative. EDATE handles short months by moving to the month's last day, so Tom's month birthday in February is the 28th.

On 3 November 2026 Tom has had 321 complete months since birth. EDATE lands on 31 October 2026, three days before the as-of date. Put the three parts together and the full label is =DATEDIF(B5,$H$1,"y")&" years, "&DATEDIF(B5,$H$1,"ym")&" months, "&($H$1-EDATE(B5,DATEDIF(B5,$H$1,"m")))&" days".

If the result shows as a date like Jan 3, 1900, the cell picked up a date format from the subtraction. Set it to General or Number.

=DATEDIF(B5,$H$1,"y")&" years, "&DATEDIF(B5,$H$1,"ym")&" months, "&($H$1-EDATE(B5,DATEDIF(B5,$H$1,"m")))&" days"

Result: 26 years, 9 months, 3 days

"26 years, 9 months, 3 days" for Tom Becker. On 1 March 2026 the same formula gives "26 years, 1 months, 1 days"; use the IF pattern from the label section if you need singulars.

Keep the as-of date in one cell

You could write TODAY() inside every formula, but a fixed as-of cell is better for most real sheets. The ages on a printed register or an exported report stay as they were on that day. You can answer "how old will they be on 1 September?" for a school or club cut-off by changing one cell. And when you want live ages, type =TODAY() into H1 and every formula follows.

It also makes birthdays easy to check. Leo Alvarez turns 7 on 4 November, one day after the as-of date, so today he is 6 years and 11 months. Change H1 to 4 November and he becomes "7 years, 0 months".

Guard the formulas against a birth date after the as-of date, which DATEDIF answers with #NUM!. That happens with typos, with future dates, and with two-digit years: with default settings Excel reads 1/5/29 as 2029 but 1/5/30 as 1930. Wrap the label in =IF(B2>$H$1,"Check date",...) or IFERROR so a bad row stands out instead of breaking totals.

=DATEDIF(B3,$H$1,"y")&" years, "&DATEDIF(B3,$H$1,"ym")&" months"

Result: 6 years, 11 months

"6 years, 11 months" for Leo, whose 7th birthday is the day after the as-of date.

Which age to use: label, months or number

Use the text label for display: badges, letters, a member list. It is text, so it cannot be sorted or averaged sensibly; "10 years" sorts before "9 years". Sort by the date of birth instead (oldest first is ascending).

Use total months, DATEDIF with "m", when ages are compared in months: nursery rooms, under-2 groups, product age ranges. Use whole years, DATEDIF with "y", for age brackets, COUNTIFS bands and eligibility checks. For a decimal age you can average, DATEDIF "m" divided by 12 gives 34.58 for Maya. Excel's YEARFRAC also returns decimal years, but it counts days, so its decimals do not line up neatly with months.

=DATEDIF(B7,$H$1,"m")

Result: 9

9 complete months for Sam Okafor.

Common mistakes

Using DATEDIF "md" for the days

It can return negative or wrong values around the 29th to 31st. Use as-of minus EDATE(birth, DATEDIF(birth, as-of, "m")).

Putting the dates in the wrong order

DATEDIF needs the earlier date first. Birth date, then as-of date; the other way round gives #NUM!.

Dates of birth stored as text

Text dates, such as imports in another country's format, give #VALUE!. Check with =ISNUMBER(B2) and convert them to real dates first.

Sorting by the age label

Labels are text, so they sort alphabetically. Sort by date of birth, or by a DATEDIF "m" column.

FAQ

How do I calculate age in years and months in Excel?

Use =DATEDIF(B2,$H$1,"y")&" years, "&DATEDIF(B2,$H$1,"ym")&" months", with the date of birth in B2 and the as-of date in H1. Replace $H$1 with TODAY() for an age that updates daily.

How do I calculate age in years, months and days?

Join "y", "ym" and a safe day count: =DATEDIF(B2,$H$1,"y")&" years, "&DATEDIF(B2,$H$1,"ym")&" months, "&($H$1-EDATE(B2,DATEDIF(B2,$H$1,"m")))&" days". Avoid DATEDIF "md", which Microsoft warns can be inaccurate.

How does Excel handle a 29 February birthday?

DATEDIF counts the year as complete on 1 March in non-leap years. Zoe Park, born 29 February 2008, shows 17 years on 28 February 2026 and 18 on 1 March 2026.

Why does DATEDIF return #NUM!?

The start date is after the end date: a future or mistyped birth date, or a two-digit year Excel read as 20xx. Check the date of birth and keep it first in the formula.

Can Excel calculate an age from a birth date before 1900?

Not with date functions. Excel's dates start on 1 January 1900, so earlier dates stay as text and DATEDIF returns #VALUE!. You would have to work with the year, month and day as separate numbers.

Functions used

Related guides

Updated