English
/

How to Calculate Age in Excel and Google Sheets

Last edited Nov 6, 2026 · 3 min read

To calculate age in years, put the date of birth in A2 and use =DATEDIF(A2, TODAY(), "Y"). It returns the number of complete years between the two dates. For age as of a specific date instead of today, replace TODAY() with a cell that holds that date. The same formula works in Excel and in Google Sheets.

On this page▾
  1. The formulas
  2. Worked example
  3. YEARFRAC for a decimal age
  4. The "MD" caveat

The formulas

Goal Formula Notes
Age in years, today =DATEDIF(A2, TODAY(), "Y") Complete years
Age in years, on a given date =DATEDIF(A2, B2, "Y") B2 holds the "as of" date
Months after the last birthday =DATEDIF(A2, B2, "YM") 0 to 11
Days after the last full month =DATEDIF(A2, B2, "MD") See the caveat below
Truncated YEARFRAC estimate =INT(YEARFRAC(A2, B2, 1)) Basis 1 is Actual/actual

Microsoft Support describes DATEDIF as calculating the number of days, months, or years between two dates, and says it is useful in formulas that calculate an age. The unit "Y" is the number of complete years in the period, "YM" is the difference between the months of the two dates with days and years ignored, and "MD" is the difference between the days with months and years ignored. Google's help page describes "YM" as the number of whole months after subtracting whole years, and "MD" as the number of days after subtracting whole months. If the start date is later than the end date, Excel returns a #NUM! error.

TODAY() returns the current date when the spreadsheet recalculates. In Excel, Microsoft says to check that calculation is set to Automatic if the date does not update as expected. A fixed "as of" date in a cell does not move with the current date.

Worked example

Date of birth 25 August 1990, end date 28 October 2026:

  • =DATEDIF(A2, B2, "Y") gives 36
  • =DATEDIF(A2, B2, "YM") gives 2
  • =DATEDIF(A2, B2, "MD") gives 3

That reads as 36 years, 2 months, 3 days. To show it in one cell: =DATEDIF(A2,B2,"Y")&" years, "&DATEDIF(A2,B2,"YM")&" months, "&DATEDIF(A2,B2,"MD")&" days".

A plain date calculation confirms each part:

from datetime import date

dob, end = date(1990, 8, 25), date(2026, 10, 28)

years = end.year - dob.year - ((end.month, end.day) < (dob.month, dob.day))
months = (end.month - dob.month - (end.day < dob.day)) % 12
days = end.day - dob.day  # valid here because end.day >= dob.day

print(years, months, days)   # 36 2 3
print((end - dob).days)      # 13213 total days

Adding 36 years and 2 months to 25 August 1990 gives 25 October 2026, and 3 more days reaches 28 October 2026, so the three parts add back to the end date.

YEARFRAC for a decimal age

YEARFRAC returns the fraction of a year between two dates. Microsoft lists the day-count basis options: 0 or omitted is US (NASD) 30/360, 1 is Actual/actual, 2 is Actual/360, 3 is Actual/365, and 4 is European 30/360. Google's page lists the same conventions. The default is 0. Specify basis 1 for an actual-day year fraction rather than accepting the financial 30/360 default. Use DATEDIF with "Y" for complete calendar years; truncating a year fraction is not a general guarantee of the same birthday-based result. Microsoft warns that YEARFRAC may return an incorrect result with the 30/360 basis when the start date is the last day of February. Google's help page also shows an age built from YEARFRAC, TODAY, and ROUNDDOWN.

For the example above, =INT(YEARFRAC(A2, B2, 1)) also returns 36. In Excel, enter dates with the DATE function or as cell references rather than as text, which Microsoft says can cause problems.

The "MD" caveat

Microsoft states that it does not recommend the "MD" unit, because the result may be a negative number, a zero, or an inaccurate one. Its page shows a workaround that subtracts the first day of the end date's month, adapted here as =B2-DATE(YEAR(B2), MONTH(B2), 1). That counts days since the start of the ending month, not days since the last birth-date-based monthly anniversary. In the example it returns 27, not 3, so it is not a drop-in replacement in the combined age formula. Microsoft also notes that DATEDIF is provided to support older Lotus 1-2-3 workbooks and may calculate incorrect results in some scenarios.

For other date arithmetic, see the guide to DATEDIF, NETWORKDAYS and EDATE.

Sources

  1. Microsoft Support, DATEDIF function
  2. Microsoft Support, YEARFRAC function
  3. Microsoft Support, TODAY function
  4. Google Docs Editors Help, DATEDIF
  5. Google Docs Editors Help, YEARFRAC

About this guide

Howlane operator · Checked against the official sources listed above. It is general information, not professional advice.

AboutEditorial standardsCorrectionsReport an error

Edit history

  • Updated
  • Updated
  • Updated
  • Updated
  • Published