How-to recipes · Dates and times
How to calculate age in Excel
Calculate someone's age in whole years from a date of birth with DATEDIF or YEARFRAC, show years, months and days, and avoid the common errors.
HR lists, school registers, membership databases and insurance quotes all need a person's age, and it must be right on the day of the birthday, not a day early or late. Subtracting the birth year from the current year is the first thing most people try, and it is wrong for everyone who has not had their birthday yet this year. Dividing the number of days by 365 is wrong around birthdays because of leap years. This recipe shows the formula that counts completed years correctly, plus variations for exact ages and ages on a specific date.
The example data
Four people and their dates of birth in A1:B5. Normally you would compare with TODAY(), but to make the example reproducible the reference date is fixed in E1: 03 December 2026.
Age in completed years: DATEDIF
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Name | Born | As of | 2026-12-03 | |
| 2 | Maria | 1990-07-15 | 36 | ||
| 3 | John | 2000-12-04 | |||
| 4 | Anna | 2008-02-29 | |||
| 5 | Liam | 1985-12-03 |
Maria was born on 15 July 1990 and has had her 36th birthday.
Result: 36
In a live sheet replace $E$1 with TODAY: =DATEDIF(B2,TODAY(),"y"). Copied down, the formula gives 25 for John, who turns 26 the day after the reference date. A plain YEAR(TODAY())-YEAR(B3) would already say 26, which is wrong by a year.
DATEDIF takes a start date, an end date and a unit. "y" returns the number of whole years between the dates. The function works in every version from Excel 2000 to Microsoft 365, but it is a compatibility function that does not appear in the formula autocomplete list, so you have to type it completely. The start date must not be later than the end date, otherwise it returns #NUM!.
Years, months and days
Other units give the remaining months and days after the whole years and months:
=DATEDIF(B2,$E$1,"y")&" years, "&DATEDIF(B2,$E$1,"ym")&" months, "&DATEDIF(B2,$E$1,"md")&" days"For Maria the result is 36 years, 4 months, 18 days. "ym" counts months ignoring the years, and "md" counts days ignoring months and years.
"md" unit can return wrong results in some situations, such as when the start day is the 31st and the end month is shorter. Use it for display only and check edge cases; for calculations, prefer whole years or a total number of days.Alternative: YEARFRAC
YEARFRAC returns the fraction of a year between two dates. With basis 1 (actual days) and INT to cut off the decimals, it gives the age in completed years:
=INT(YEARFRAC(B2,$E$1,1))It returns 36 for Maria as well, and it is a documented function that appears in autocomplete. Without INT, =YEARFRAC(B2,$E$1,1) gives an exact decimal age (about 36.4), which is useful for statistics such as an average age. In rare cases very close to a birthday, YEARFRAC's day-count rules can differ from the calendar answer by a day, so DATEDIF is the better choice for legal ages.
Age on a specific date
Use any date as the end date: the age at the start of the school year, at the policy start, at the end of the tax year. Build it with DATE for clarity: =DATEDIF(B2,DATE(2027,9,1),"y") returns the age on 1 September 2027. The age when someone reaches a limit, such as the date of their 67th birthday, is =EDATE(B2,12*67).
Leap-day birthdays
Anna was born on 29 February 2008. DATEDIF treats her birthday in non-leap years as 1 March, so on 03 December 2026 she is 18 and she turns a year older on 1 March in years without 29 February. Some countries legally use 28 February instead; if that matters, check the rule that applies to you.
Pitfalls
- Dates stored as text give
#VALUE!. Imported birth dates often are text; convert them first (How to convert text to a date in Excel). - Result shown as a date. If the age appears as something like 05-Feb-1900, the cell inherited a date format. Set it to General.
- TODAY() changes every day, which is what you want for a live list but not for a report that must stay as it was. Put a fixed reference date in a cell for reports.
- Divide by 365.25 is a popular shortcut (
=INT((E1-B2)/365.25)) but gives the wrong answer on or just before some birthdays. Use DATEDIF.