Age in years, months, and days between any two dates is the gap measured one unit at a time: count full years first, then the leftover full months, then the remaining days, stepping forward from the earlier date until one more unit would overshoot the later one. This borrow order — years, then months, then days — is what makes age math correct when the calendar refuses to cooperate. Naive subtraction of day-from-day and month-from-month breaks on short months (28, 29, or 30 days), on February 29 birthdays, and on any reference date that falls in a different month than the birth date. Excel exposes a built-in function, DATEDIF, that performs this exact calculation when paired with the right unit codes, but its lowest-level "MD" option has a long-standing quirk that can return values outside the 0–27 range. A free in-browser Age Calculator does the borrow-stepped arithmetic the way trusted date libraries do — instantly, with no formula to write and no date ever leaving your device.

how to calculate age in excel from two dates
how to calculate age in excel from two dates

Why Naive Date Subtraction Gets Age Wrong

Most age formulas start with the obvious move: subtract the year, subtract the month, subtract the day. That works for birthdays on or before the same calendar day each year, and fails everywhere else.

Take a real example. Suppose someone's date of birth is January 31, 2000 and you want their age on March 1, 2025. The naive approach says:

  • Years: 2025 − 2000 = 25
  • Months: 3 − 1 = 2
  • Days: 1 − 31 = −30

Twenty-five years, two months, minus thirty days. That is nonsense — you cannot be negative thirty days old.

The correct answer is 25 years, 1 month, 1 day. Here is why: starting from January 31, 2000, step forward 25 full years to January 31, 2025. Adding one full month from January 31 lands on February 28 (because 2025 is not a leap year). Adding one more day from February 28 reaches March 1, 2025 — exactly the target. The borrow order is what kept every value non-negative.

The same rule explains why the "clever" shortcut =(B1-A1)/365.25 is also wrong. It returns a decimal that is approximately right but never exact, and it cannot separate years, months, and days at all.

Excel's Built-In Method: DATEDIF for Years, Months, Days

Excel ships a function specifically designed for this calculation: DATEDIF(start_date, end_date, unit). The third argument picks which unit to count:

  • "Y" — complete years between the two dates
  • "M" — complete months between the two dates
  • "D" — complete days between the two dates
  • "YM" — months after the last full year (0–11)
  • "MD" — days after the last full month (0–27, but with a quirk — see below)
  • "YD" — days after the last full year (0–364)

To get the full years-months-days breakdown in a single cell, chain the three leftover-stepping variants:

=DATEDIF(A1,B1,"Y")&"y "&DATEDIF(A1,B1,"YM")&"m "&DATEDIF(A1,B1,"MD")&"d"

Place the earlier date in A1 and the later date in B1. For the January 31, 2000 → March 1, 2025 example above, this formula returns "25y 1m 1d" — the correct answer.

One known issue: the "MD" unit does not always honor the borrow-stepped method on short months. On some Excel versions, the same inputs return "25y 1m −1d" or "25y 1m 30d". The widely used workaround is DATEDIF(A1+1, B1+1, "MD") with both arguments shifted by one day, which nudges the calculation past the bug. If you want a result that is always right without maintaining a workaround, jump to the Age Calculator section below.

Calculating Exact Age from Two Dates, Step by Step

Here is a complete Excel procedure for getting years, months, and days from any two dates:

  1. Open a blank worksheet and type the earlier date in cell A1 (for example, 2000-01-31).
  2. Type the later date in cell B1 (for example, 2025-03-01).
  3. In cell C1, enter =DATEDIF(A1,B1,"Y") for the full years component.
  4. In cell C2, enter =DATEDIF(A1,B1,"YM") for the leftover full months after the last full year.
  5. In cell C3, enter =DATEDIF(A1,B1,"MD")+0 for the leftover days after the last full month — the +0 just forces a numeric value.
  6. In cell C4, combine them with =C1&" years, "&C2&" months, "&C3&" days".
  7. For total calendar days, enter =B1-A1 in C5 and format it as a number.
  8. For total whole weeks, enter =INT((B1-A1)/7) in C6; add =MOD(B1-A1,7) in C7 for the leftover days.

Running this with January 31, 2000 in A1 and March 1, 2025 in B1 produces 25 years, 1 month, 1 day, plus the total day count for the full span. Every cell is auditable, every formula is short, and you can drag the rows down to apply the same pattern to a list of names and dates.

Edge Cases That Break Most Excel Formulas

Three calendar quirks account for most age-calculation bugs.

Short months. Months have 28, 29, 30, or 31 days — never a fixed 30. When borrowing, the borrowed amount must match the actual calendar month you are stepping into. February 2025 has 28 days, so January 31 + 1 month = February 28. February 2024 (a leap year) has 29 days, so January 31 + 1 month = February 29 in that year.

Leap years. The Gregorian rule: a year is a leap year if divisible by 4, except century years, which must also be divisible by 400. That makes 2000 a leap year but 1900 and 2100 not. February 29 exists only in leap years, and any age calculation that crosses Feb 29 needs to count the extra day in totals.

February 29 birthdays. February 29 exists only every four years (with the century exception above). For a person born on this day, the convention observed in much of Europe and in many legal systems treats February 28 as the birthday in common years, so they still gain a full year every year rather than only once every four.

Compare the four common Excel approaches side by side:

MethodWhat it returnsWhere it breaks
=DATEDIF(A1,B1,"Y")Full years onlyHides months and days entirely
Chained DATEDIF (Y + YM + MD)Years, months, days breakdownThe "MD" unit can misfire on short months; needs a +1 workaround
=YEARFRAC(A1,B1)Decimal years (e.g. 25.09)Basis-dependent; cannot show months/days; leap-year sensitive
=INT((B1-A1)/365.25)Approximate integer yearsOff by roughly one day per century; cannot produce months or days

Each approach works for some inputs and silently miscalculates for others. The gap between "looks fine in the easy cases" and "actually correct across the calendar" is what the borrow-stepped method — the same arithmetic trusted date libraries use — closes.

When You Need Totals Instead of Y/M/D

Some questions are easier to answer in a single unit. A baby's age in weeks, an anniversary counted in days, an insurance or pension eligibility threshold — these come up often and want one number, not a triple.

Total days is the exact calendar-day count between the two dates, using each month's real length and counting every leap day in between. Total weeks is that day count divided by seven and rounded down. Total months is the number of whole months elapsed over the same span. These totals describe the same span as the years-months-days breakdown, just expressed in one unit, so a future date two months out might read as 0 years, 2 months, about 60 days, and about 8 weeks all at once.

Excel returns totals with =B1-A1 for days and =INT((B1-A1)/7) for whole weeks, and these simple arithmetic cells are reliable once the underlying dates are correct. The YMD breakdown is what needs the careful borrow logic; the totals do not.

A Faster Path: Use the Age Calculator

If the goal is the answer, not the formula, the Age Calculator handles all of this in one screen. Pick your date of birth in the first field — your exact age appears instantly, with no button to press. Leave the second field on today, or set it to any past or future date to find your age at that exact moment. You get years, months, and days, plus total months, weeks, days, and a live countdown to your next birthday.

The arithmetic runs in your browser using the borrow-stepped method, the same logic date-fns and similar trusted libraries use. That means it handles short months, leap years, and February 29 birthdays the way you expect, including the February 28 convention in common years. Every input stays on your device — no date ever leaves — so you can use it for sensitive records without any upload risk. The result updates the instant you change a field, so you can scrub through past and future reference dates and watch your age change.

For Excel work specifically, the cleanest workflow is: type the two dates into the spreadsheet for your records, then open the Age Calculator to confirm the breakdown whenever a cell gives an unexpected number. The two-minute check is faster than chasing an "MD" quirk through forums.