Age Calculation Based on Date of Birth Excel
In this article
Age calculation based on date of birth in Excel uses built-in functions to determine a person's age in years, months, or days from their birth date to a specified end date—usually today. The most accurate method uses the DATEDIF function, which is not officially documented but widely supported and reliable for calculating complete time intervals.
Background on Date Handling in Excel
Excel stores dates as serial numbers, where January 1, 1900, is serial number 1, and each subsequent day adds 1. This system allows Excel to perform arithmetic operations on dates, such as adding or subtracting days or calculating differences. For example, the date January 1, 2000, is serial number 36526. This numeric foundation makes it possible to compute durations, including age, by subtracting one date from another.
This date system has two main versions: the 1900 date system (default for Windows) and the 1904 date system (default for older Mac versions). The 1904 system starts on January 1, 1904, to avoid a known leap year bug in the 1900 system. When sharing workbooks between platforms, this can cause date shifts, so it's important to ensure consistent settings under Excel Options > Advanced > Use 1904 date system.
How Age Calculation Works in Excel
The core of age calculation is determining the difference between two dates: the date of birth and the end date (typically TODAY()). While simple subtraction gives the number of days between dates, converting that into human-readable years, months, and days requires more precision.
The best method uses the DATEDIF function, which takes three arguments: start date, end date, and a unit. Despite being undocumented by Microsoft, it remains fully functional in all modern versions of Excel.
Syntax: DATEDIF(start_date, end_date, unit)
Common units include:
- "Y" – Complete years between dates
- "M" – Complete months between dates
- "D" – Complete days between dates
- "YM" – Months between dates, ignoring years
- "YD" – Days between dates, ignoring years
- "MD" – Days between dates, ignoring months and years
For example, to calculate age in years: =DATEDIF(A2, TODAY(), "Y") where A2 contains the birth date.
Step-by-Step Age Calculation Methods
Here are practical approaches to calculate age in Excel:
- Age in Complete Years:
=DATEDIF(A2, TODAY(), "Y") - Age in Years and Months:
=DATEDIF(A2, TODAY(), "Y") & " years, " & DATEDIF(A2, TODAY(), "YM") & " months" - Full Age (Years, Months, Days):
=DATEDIF(A2, TODAY(), "Y") & " years, " & DATEDIF(A2, TODAY(), "YM") & " months, " & DATEDIF(A2, TODAY(), "MD") & " days" - Age Using YEARFRAC (Decimal Years):
=INT(YEARFRAC(A2, TODAY()))– This returns whole years but may round differently than DATEDIF.
For static calculations (e.g., age on a past or future date), replace TODAY() with a specific date, such as DATE(2025,12,31).
Common Problems and Errors
Several issues arise when calculating age in Excel:
- #NUM! Error: Occurs if the start date is later than the end date. Ensure the birth date is valid and entered correctly.
- Incorrect Age Due to Formatting: If a cell displays a number like 45100 instead of a date, apply proper date formatting (Home > Number > Short Date).
- DATEDIF Not Recognized: Although not in the function list or IntelliSense, DATEDIF works when typed manually. No add-in is needed.
- Leap Year and Month Edge Cases: DATEDIF correctly handles leap years and variable month lengths (e.g., February 29 to March 1).
- Using (TODAY() - A2)/365: This method is inaccurate because it assumes every year has 365 days, ignoring leap years and giving incorrect fractional results.
To avoid errors, always validate input dates using data validation or the ISDATE function.
Alternatives to DATEDIF
While DATEDIF is the most accurate, alternative formulas exist:
- YEARFRAC Function:
=INT(YEARFRAC(A2, TODAY()))– Calculates the fraction of the year between dates and truncates to whole years. However, it may return one year more or less depending on the basis used (optional third argument). - Manual Calculation:
=YEAR(TODAY()) - YEAR(A2)– This only compares calendar years and does not account for whether the birthday has occurred this year, so it can be off by one year. - Combination of YEAR, MONTH, DAY: More complex logic using nested IF statements to adjust for unpassed birthdays, but error-prone and unnecessary when DATEDIF is available.
DATEDIF remains superior because it calculates complete intervals, not just differences in year numbers.
Frequently Asked Questions
Why doesn't DATEDIF appear in Excel's function list?
DATEDIF is a legacy function from Lotus 1-2-3 compatibility and is intentionally undocumented by Microsoft. However, it is fully functional in all current versions of Excel, including Microsoft 365.
How do I calculate age on a specific date, not today?
Replace TODAY() with the target date. For example: =DATEDIF(A2, DATE(2023,12,31), "Y") calculates age as of December 31, 2023.
Can I calculate age in months or days only?
Yes. Use DATEDIF(A2, TODAY(), "M") for total completed months, or DATEDIF(A2, TODAY(), "D") for total days. For age in months including years, combine units: =DATEDIF(A2, TODAY(), "Y")*12 + DATEDIF(A2, TODAY(), "YM").
What if the birth date is missing or invalid?
Wrap the formula in IF and ISDATE to handle blanks: =IF(ISDATE(A2), DATEDIF(A2, TODAY(), "Y"), "Invalid Date").
Does DATEDIF work in Google Sheets?
Yes, DATEDIF works in Google Sheets with the same syntax and units. It is documented and supported there, unlike in Excel.
How do I calculate age for someone born on February 29?
DATEDIF handles leap day births correctly. For non-leap years, it treats March 1 as the birthday. For example, someone born on February 29, 2000, will turn 1 year old on March 1, 2001, and DATEDIF returns accurate results.