Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Excel Age Function: How to Calculate Age Automatically

· 4 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To calculate age in Excel, use the DATEDIF function. The most common formula is =DATEDIF(birthdate_cell, TODAY(), "y"), which calculates the number of complete years between a specific birthdate and the current date. While Excel does not list DATEDIF in its standard function autocomplete menu, it is a fully supported "hidden" function used for calculating the difference between two dates in years, months, or days.

What You'll Need

  • A computer with Microsoft Excel installed (all versions).
  • A dataset containing birthdates formatted as Date cells.
  • Basic knowledge of how to enter a formula into a cell.

Step-by-Step

  1. Prepare Your Data: Ensure your birthdates are in a consistent column. For example, place the birthdates in Column A, starting at cell A2. Ensure these cells are formatted as "Date" (Right-click cell > Format Cells > Date).
  2. Select the Target Cell: Click on the cell where you want the age to appear (e.g., cell B2).
  3. Enter the DATEDIF Function: Type the following formula exactly as shown: =DATEDIF(A2, TODAY(), "y").
    • A2: This is the start date (the birthdate).
    • TODAY(): This tells Excel to use the current date from your system clock, ensuring the age updates automatically every time you open the file.
    • "y": This is the interval code. "y" tells Excel to return the difference in complete years.
  4. Press Enter: Hit the Enter key. The cell will now display the person's current age as a whole number.
  5. Apply to the Entire Column: To calculate the age for the rest of your list, click the small green square (the fill handle) in the bottom-right corner of cell B2 and drag it down to the end of your data range.
  6. Verify the Result: Double-check a few entries to ensure the calculation is correct based on today's date.

Common Mistakes

  • Incorrect Date Formatting: If the birthdate cell is formatted as "Text" instead of "Date," the formula will return a #VALUE! error. Always ensure your input dates are recognized by Excel as dates.
  • Swapping the Date Order: The DATEDIF function requires the start date (birthdate) to come before the end date (today). If you put TODAY() first, Excel will return a #NUM! error because it cannot calculate a negative age.
  • Forgetting the Quotes: The interval code (e.g., "y") must be enclosed in double quotation marks. Typing =DATEDIF(A2, TODAY(), y) without quotes will result in a #NAME? error.
  • Using the Wrong Interval: Using "d" instead of "y" will give you the person's age in total days, which results in a very large number that may look like a date if the cell is formatted incorrectly.

Tips

  • Calculate Age as of a Specific Date: If you need to know how old someone was on a specific date (e.g., for a school enrollment cutoff), replace TODAY() with a cell reference containing that specific date. Example: =DATEDIF(A2, C2, "y").
  • Adding "Years" Text: To make the result more readable, you can concatenate the word "Years" to the end of the formula. Use: =DATEDIF(A2, TODAY(), "y") & " Years".
  • Calculating Precise Age (Years, Months, Days): You can combine multiple DATEDIF functions to get a highly detailed age. Use this formula for a result like "25 Years, 3 Months, 2 Days":
    =DATEDIF(A2, TODAY(), "y") & " Years, " & DATEDIF(A2, TODAY(), "ym") & " Months, " & DATEDIF(A2, TODAY(), "md") & " Days".
  • Using "ym" and "md": In the detailed formula above, "ym" ignores the years and calculates the remaining months, while "md" ignores the months and years to calculate the remaining days.

Troubleshooting

If the formula does not go to plan, try these steps in order:

  1. Check for #VALUE! Error: This usually means your date is not a valid date. Select the cell, go to the "Home" tab, and change the number format dropdown to "Short Date." If the date doesn't change alignment or format, you may need to re-type it.
  2. Check for #NUM! Error: Ensure the birthdate is actually in the past. If the date in cell A2 is later than today's date, DATEDIF will fail.
  3. Check for #NAME? Error: Check your spelling of DATEDIF and ensure the "y" is inside double quotes.
  4. Check Cell Formatting: If the result looks like a weird date (e.g., 1/15/1900) instead of a number like 30, the result cell is formatted as a "Date." Change the cell format to "General" or "Number" to see the actual age.

Frequently Asked Questions

Why doesn't DATEDIF appear in the formula list?

DATEDIF is a legacy function kept for compatibility with older spreadsheet software. Microsoft does not include it in the autocomplete suggestions, but it works perfectly when typed manually.

Can I use the YEARFRAC function instead?

Yes, =YEARFRAC(A2, TODAY()) calculates age, but it returns a decimal (e.g., 25.42). To get a whole number, you would need to wrap it in the INT function: =INT(YEARFRAC(A2, TODAY())).

Will the age update automatically tomorrow?

Yes, because the formula uses the TODAY() function, Excel checks your system clock every time the workbook is opened or recalculated, updating the age automatically.

Does this work in Google Sheets?

Yes, the DATEDIF function uses the exact same syntax and interval codes ("y", "m", "d") in Google Sheets as it does in Microsoft Excel.

What is the difference between "y" and "ym"?

The "y" interval calculates the total number of full years between two dates. The "ym" interval calculates the number of months remaining after the full years have been subtracted.