FORMULAS & FUNCTIONS
How to Calculate Age in Excel with DATEDIF (Years, Months, Days)
To calculate age in Excel from a date of birth, use =DATEDIF(birth date, today, “Y”). It returns completed years, the way people count their age. This guide shows the formula as of today or a specific date, the age in years, months and days, the YEARFRAC alternative, how to avoid the #NUM! error and the blank-date trap, and how to use the same formulas for a team: ages, years of service, next birthdays and age bands, with a free workbook.

The age formula in Excel
=DATEDIF(C3,C4,"Y")
- C3: the date of birth (the start date).
- C4: the date you want the age on. Use
=TODAY()for today, or type a date for a specific date such as a month end. - “Y”: the unit, completed years. Other units:
"M"months,"D"days,"YM"months after the last birthday,"MD"days after the last full month.
Step 1: Age in years with DATEDIF
Enter the date of birth in C3 and the as-of date in C4, then in C7:
=DATEDIF(C3,C4,"Y")
Someone born on Mar 18, 1988 is 38 on Oct 31, 2026. DATEDIF counts completed years, so they stay 38 until Mar 18, 2027. A simple =(C4-C3)/365 looks close but drifts with leap years and can show the new age a day early or late.

If the result looks wrong, check that both dates are real dates, not text. A date typed as text gives #VALUE!; see how to standardize mixed date formats.
Step 2: Age in years, months and days
Add the months after the last birthday and the days after the last full month:
=DATEDIF(C3,C4,"YM")
=C4-EDATE(C3,DATEDIF(C3,C4,"M"))
The first gives 7 months. The second counts total months, moves the birth date forward by that many months with EDATE, and subtracts: 13 days. You can also use DATEDIF(C3,C4,"MD"), which gives 13 here, but Microsoft warns that “MD” can return wrong results for some dates, so the EDATE version is the safer choice. Join the parts into one line of text:
=C7&" years, "&C8&" months, "&C10&" days"

The text result cannot be used in calculations; keep the numbers in their own cells. To format dates inside text, use TEXT, as in month labels with the TEXT function.
Step 3: Total months, total days and YEARFRAC
| Result | Formula | Value |
|---|---|---|
| Total months | =DATEDIF(C3,C4,"M") | 463 |
| Total days | =C4-C3 | 14,106 |
| Age with decimals | =YEARFRAC(C3,C4,1) | 38.62 |
| Age in whole years | =INT(YEARFRAC(C3,C4,1)) | 38 |
Subtracting two dates gives days, because Excel stores dates as day numbers. YEARFRAC returns the fraction of years between two dates; basis 1 uses the actual days in each year. INT drops the decimals, so =INT(YEARFRAC(C3,C4,1)) is an alternative age formula that shows up in autocomplete. The workbook checks it against DATEDIF in C16: Ties.

Step 4: Avoid #NUM! and blank-date surprises
Two things go wrong in real lists. If the start date is after the end date (a typo, or a future date), DATEDIF returns #NUM! in Excel. Check the order first:
=IF(C3>C4,"Check dates",DATEDIF(C3,C4,"Y"))
And if the date of birth is blank, Excel treats it as 0, a date in 1900, so the age shows as 126 instead of an error. Return a blank instead:
=IF(C3="","",DATEDIF(C3,C4,"Y"))

For other errors, wrap the formula in IFERROR, but only after you know why the error happens; see IFERROR in Excel.
Step 5: Ages and years of service for a team
On the Employees sheet, the as-of date is in C2 and each row has a date of birth and a hire date. The same formulas work down the list, with the as-of date locked by $:
=DATEDIF(B5,$C$2,"Y")
=E5&" yrs "&DATEDIF(C5,$C$2,"YM")&" mos"
The first is the age; with the hire date in C5 instead of B5, the same formula gives completed years of service (E5). The second shows the service as years and months, which is how service awards, probation periods and leave entitlements are usually measured.

Service-based leave? Combine years of service with an employee leave tracker. For working days between two dates rather than calendar time, use NETWORKDAYS with holidays.
Step 6: Next birthday and age bands
The next birthday is the date of birth plus (age + 1) years. EDATE adds months, so multiply by 12. If the birthday is today, show today:
=IF(EDATE(B5,12*D5)=$C$2,$C$2,EDATE(B5,12*(D5+1)))
Days to birthday is the next birthday minus the as-of date. Ana Reyes turns 35 on Nov 4, 2026, in 4 days; David Cruz’s birthday is the as-of date itself, so it shows 0. For Carla Mendoza, born on Feb 29, 2000, EDATE returns Feb 28, 2027, the last day of February in a non-leap year.
Count people in each age band with COUNTIFS, using the band limits in columns B and C:
=COUNTIFS($D$5:$D$12,">="&B15,$D$5:$D$12,"<="&C15)
The bands add up to 8, the headcount (check: Ties). For more on counting with two conditions on one column, see COUNTIFS with multiple criteria.

Common age formula mistakes
| Symptom | Cause | Fix |
|---|---|---|
| Age is one year too high before the birthday | YEAR(C4)-YEAR(C3) subtracts calendar years only | Use DATEDIF with “Y”, which checks the month and day |
| Age changes every day the file opens | The as-of date is =TODAY() | Type a fixed date for reports you need to keep |
| #VALUE! | A date is stored as text | Convert the text to real dates first |
| #NUM! | The start date is after the end date | Put the date of birth first, or guard with IF |
| Age shows 126 | The date of birth is blank | Return “” when the cell is empty |
| Result shows as a date, like Feb 7, 1900 | The cell has a date format | Format the result cell as Number or General |
The last one surprises many people: when you type a formula next to a date column, Excel may copy the date format into the result. The age is right; only the format is wrong.
Frequently asked questions
How do I calculate age in Excel from a date of birth?
=DATEDIF(birth date,TODAY(),”Y”). Replace TODAY() with a cell containing a date to get the age on a specific date.
How do I show age in years and months?
=DATEDIF(B2,TODAY(),”Y”)&” years, “&DATEDIF(B2,TODAY(),”YM”)&” months”.
Why is DATEDIF not in Excel?
It is a hidden compatibility function. It does not appear in autocomplete or the function list, but it works when you type it in full.
Why does DATEDIF return #NUM!?
The start date is after the end date. Check the order with IF, or swap the arguments.
Is there an alternative to DATEDIF?
=INT(YEARFRAC(birth date,as-of date,1)) gives the same completed years in normal cases.
Final checklist
- Both dates are real dates, not text.
- The date of birth is the first argument and the as-of date the second.
- The as-of date is fixed for a report, or =TODAY() for a live list.
- Days use the EDATE version instead of “MD”.
- Blank and reversed dates are handled with IF.
- The as-of date is locked with $ before you copy the formula down.
Work smarter with dates
Browse the ready-to-use Excel templates for HR and business, visit the OneXcel Tutorial Hub for more date formulas, or chart your team data in the OneXcel Dashboard Builder.
