Calculate Age in Excel Using Two Dates
The beginning of the period (e.g., a birth date).
The end of the period (e.g., today’s date).
What is a “Calculate Age in Excel” Calculation?
To calculate age in Excel using two dates means finding the precise duration between a start date (like a date of birth) and an end date. While it sounds simple, accurately accounting for leap years and varying month lengths requires specific functions. This calculation is crucial for human resources, project management, and data analysis tasks where knowing an exact age or time span is necessary. Unlike simple subtraction, which can be inaccurate, using Excel’s dedicated date functions ensures precision.
How to Calculate Age in Excel: Formulas and Explanations
The most reliable way to calculate a person’s complete age in years, months, and days is by using the DATEDIF function. [3] This function is a “hidden” gem in Excel, originally from Lotus 1-2-3, but it’s perfect for this task. [10]
The main formula structure to get a full breakdown is:
=DATEDIF(start_date, end_date, "Y") & " years, " & DATEDIF(start_date, end_date, "YM") & " months, " & DATEDIF(start_date, end_date, "MD") & " days"
| Variable | Meaning | Unit | Typical Range |
|---|---|---|---|
start_date |
The cell containing the earlier date (e.g., A2). | Excel Date | Any valid date before the end date. |
end_date |
The cell containing the later date (e.g., B2 or TODAY()). |
Excel Date | Any valid date after the start date. |
"Y" |
Calculates the number of full years in the period. | Years (Integer) | 0 or greater. |
"YM" |
Calculates the number of full months after subtracting the full years. | Months (Integer) | 0 to 11. |
"MD" |
Calculates the number of days after subtracting full years and months. | Days (Integer) | 0 to 30. |
For a simpler calculation that provides the age as a decimal, you can use the YEARFRAC function. [4] For more on this, check out our guide on the YEARFRAC function in Excel.
Practical Examples
Example 1: Calculating an Employee’s Age
Imagine an employee’s birth date is in cell A2 (e.g., 15-Jun-1990) and you want to calculate their current age in cell C2.
- Inputs: Start Date =
15-Jun-1990, End Date =TODAY() - Formula:
=DATEDIF(A2, TODAY(), "Y") - Result: The formula would return the employee’s age in completed years. To see how this is done in detail, see this guide on how to calculate duration between two dates in Excel.
Example 2: Finding the Duration of a Project
A project started on 20-Jan-2023 (cell A3) and ended on 10-May-2024 (cell B3).
- Inputs: Start Date =
20-Jan-2023, End Date =10-May-2024 - Formula:
=DATEDIF(A3, B3, "Y") & " years, " & DATEDIF(A3, B3, "YM") & " months, " & DATEDIF(A3, B3, "MD") & " days" - Result: “1 years, 3 months, 20 days”.
How to Use This Age Calculator
Using this calculator is simple and provides instant, accurate results without needing to remember complex Excel formulas.
- Enter Start Date: Use the date picker to select the beginning of the period, such as a date of birth.
- Enter End Date: Select the end of the period. By default, it’s set to today, but you can change it to any date.
- View Results Instantly: The calculator automatically shows the duration in years, months, and days, along with totals in different units.
- Interpret the Chart: The bar chart provides a visual representation of the breakdown, making it easy to see the relative size of the year, month, and day components. For more complex scenarios, you might want to understand common errors in excel date formulas.
Key Factors That Affect Age Calculation
- Start Date: This is the anchor of the calculation. An incorrect start date will make the entire result wrong.
- End Date: The age is calculated up to this date. Using
TODAY()ensures the calculation is always current. - Leap Years: The
DATEDIFfunction automatically handles leap years, which is a major advantage over simple subtraction methods. - Excel’s Date System: Excel stores dates as sequential serial numbers, which allows it to perform calculations on them. This is fundamental to how functions like DATEDIF and YEARFRAC work.
- The “MD” Unit Bug: Be aware that the “MD” argument in
DATEDIFcan sometimes produce inaccurate results in specific edge cases, a known issue with the function. [10] - Time Zone Differences: If the start and end dates are in different time zones, it can affect the day count if not standardized.
Frequently Asked Questions (FAQ)
- How do you calculate age from a date of birth in Excel?
- The most common formula is
=DATEDIF(birth_date, TODAY(), "Y")to get the age in years. [1] - Why does my age formula show a #NUM! error?
- This error usually happens in
DATEDIFwhen the start date is later than the end date. [9] Ensure your dates are in the correct order. - Can I calculate age as a decimal in Excel?
- Yes, use the
=YEARFRAC(start_date, end_date, 1)formula. The `1` basis provides a more accurate calculation based on actual days. [12] - What is the difference between DATEDIF and YEARFRAC?
DATEDIFis best for getting discrete units (complete years, months, days), whileYEARFRACis for getting a fractional representation of the years between two dates. [14]- Why can’t I find DATEDIF in Excel’s function list?
DATEDIFis a compatibility function from Lotus 1-2-3. It works perfectly but is not officially documented or listed in Excel’s formula autocomplete. [16]- How does the calculator handle leap years?
- The JavaScript `Date` object, much like Excel’s functions, automatically accounts for leap years when calculating the difference between two dates, ensuring accuracy.
- What if my dates are formatted as text?
- Your formulas will return a #VALUE! error. You need to convert the text to dates first. A quick way is using the ‘Text to Columns’ feature on the Data tab. For help, see our article on fixing common Excel formula errors.
- How can I calculate the number of workdays between two dates?
- For that, you should use the
NETWORKDAYSfunction, which excludes weekends and optional holidays. This is different from a simple age calculation. This is covered in our guide to NETWORKDAYS.
Related Tools and Internal Resources
Explore more of our resources to become an Excel pro:
- Excel DATEDIF Function Deep Dive: A complete look at the most powerful function for date differences.
- The Ultimate Guide to YEARFRAC: Learn to calculate fractional years for finance and analysis.
- How to Calculate Duration Between Two Dates in Excel: Master various methods for finding the days, months, or years between any two dates.
- 10 Common Excel Formula Errors and How to Fix Them: A troubleshooter’s guide to fixing errors like #VALUE! and #NUM!.
- Calculating with Time in Excel: A primer on adding, subtracting, and formatting time values.
- Using NETWORKDAYS to Calculate Business Days: The essential function for project planning and HR.