Skip to content

Excel, Sheets and code

Age Calculator Formula | Exact Age From Date of Birth

Learn the exact age calculator formula step by step. See how years, months, and days are computed from any date of birth, with worked examples.

Quick answer

The age formula is one subtraction with two rules. Age equals the reference date minus the date of birth. Completed years come from the year difference, minus one if the birthday has not yet arrived. Exact years, months and days come from the same subtraction with calendar borrowing.

This page is the formula reference for age calculation. Every formula is stated here in one place: in plain language, in mathematical notation, and in spreadsheet form, with the borrow quiz, the ISO 8601 duration, and the month-end clamping convention.

It is not the step-by-step method. That is how to calculate age from a date of birth manually, which teaches the borrowing method with worked examples and total days. Come here when you want the formula itself, in the form you need to use it.

Gold calculator beside a blank gold calendar page with gold circles and gold stars on a deep pine green background
A gold calculator beside a blank gold calendar page with gold circles and gold stars on deep pine green.

The Formula in One Line

Age is the calendar interval between two dates: the date of birth (DOB), which is the starting date, and the reference date, which is the date on which age is being measured.

The reference date is often today, but it can also be a past or future date. The general relationship is: Age = Reference Date − Date of Birth.

If the dates are separated into individual components, the initial calculation can be written as: Years = Reference Year − Birth Year; Months = Reference Month − Birth Month; Days = Reference Day − Birth Day.

Those three subtractions are only the starting point. If the day or month result is negative, the calendar values must be adjusted. That is where the borrowing rules below come in.

Implementing this in code? See our developer’s guide to the age calculation formula with JavaScript, Python, and SQL examples. If you only need the result, use our Age Calculator instead of calculating it manually.

Completed Years: The Formula

If you only need someone’s age in full or completed years, you do not need to calculate months and days separately. The formula is: Completed age = Reference Year − Birth Year − Birthday Adjustment.

The birthday adjustment is 0 if the birthday has already occurred on or before the reference date, and 1 if the birthday has not yet occurred in the reference year. In words: whole years = the reference year minus the birth year, less one when the birthday is still ahead in the reference year.

Table 1 · The Birthday Adjustment
Situation What to Do
Birthday has already occurred Keep the difference between the two years
Reference date is the birthday Keep the difference between the two years
Birthday has not occurred yet Subtract 1 from the year difference

Three cases, all with the reference date September 3, 2026. Born March 15, 2000: the year difference is 2026 − 2000 = 26, and March 15 has already passed, so the completed age is 26 years.

Born December 15, 2000: the year difference is still 26, but December 15 has not yet occurred, so the completed age is 25 years. Born September 3, 2000: the birthday has been reached on that date, so the completed age is 26 years.

Exact Age: The Formula

An exact calendar-age calculation goes beyond completed years and also determines the remaining full months and days. Start with the individual date components: Days = Reference Day − Birth Day; Months = Reference Month − Birth Month; Years = Reference Year − Birth Year.

If every result is zero or positive, the calculation is straightforward. If days or months become negative, calendar borrowing is required. The two borrowing rules: if days go negative, borrow the previous month’s days and reduce the month by 1; if months go negative, borrow 12 months and reduce the year by 1.

The borrowing must respect the actual calendar. You cannot safely assume that every borrowed month contains 30 days, because calendar months contain 28, 29, 30, or 31 days.

Worked example: July 28, 1995 to March 15, 2026

Date of birth: July 28, 1995. Reference date: March 15, 2026. This example requires both a day adjustment and a month adjustment.

Table 2 · The Worked Example, Component by Component
Component Initial Calculation Adjustment Final Result
Days 15 − 28 = −13 Borrow 28 days from February 2026: 15 + 28 − 28 15 days
Months 2 − 7 = −5 after borrowing from March Add 12 months and borrow 1 year 7 months
Years 2025 − 1995 Reference year was reduced by the month borrowing 30 years

The resulting calendar age is 30 years, 7 months, and 15 days. The same span is 11,188 total days, and the decimal age is 30.63 years.

This example also shows why age calculation is not simply three independent subtractions. The day adjustment can change the month calculation, and the month adjustment can change the year calculation.

Which Month Do You Borrow From?

Competitors state the borrowing rule. None tests it as a quiz proving why the rule matters. Borrow from the previous month’s real length, relative to the target month, not the birth month.

Table 3 · The Borrow Quiz
Birth date Target date Correct borrow Tempting wrong borrow Result
Sep 22, 1998 Aug 14, 2026 July (31 days) September (30 days) 27y 10m 23d
Mar 3, 1990 Feb 28, 2025 January (31 days) March (31 days) 34y 11m 25d
Jun 15, 2000 Mar 10, 2026 February (28 days) June (30 days) 25y 8m 23d

Getting the borrow month wrong shifts the answer by a day. The first row borrows July’s 31 days because July is the month before the August target date, not September’s 30 days from the birth month. The third row borrows February’s 28 days because February 2026 is not a leap year.

Worked Example: Born September 24, 1996

Target: May 12, 2026. Days: 12 minus 24 is negative. Borrow April’s 30 days (month 5 becomes 4): 12 + 30 – 24 = 18 days. Months: 4 minus 9 is negative. Borrow 12 (year 2026 becomes 2025): 4 + 12 – 9 = 7 months.

Years: 2025 minus 1996 = 29 years. Result: 29 years, 7 months, 18 days. Check: Sep 24, 1996 + 29y = Sep 24, 2025. Plus 7m = Apr 24, 2026. Plus 18d = May 12, 2026. Exact.

The Formula in a Spreadsheet

In a spreadsheet, completed years from the same two inputs are: =DATEDIF(DOB_cell, reference_cell, "Y") The full breakdown is: =DATEDIF(DOB_cell, reference_cell, "Y")&" years, "&DATEDIF(DOB_cell, reference_cell, "YM")&" months, "&DATEDIF(DOB_cell, reference_cell, "MD")&" days" For the full spreadsheet treatment, see how to calculate age in Excel and how to calculate age in Google Sheets.

When you need one answer and no spreadsheet, the age on a specific date calculator is quicker.

The Formula in Code

The same formula in code subtracts the dates component by component and applies the same two borrowing rules. Our developer’s guide gives the JavaScript, Python, and SQL versions, with the month-end clamping rule included. The reference date in code is a parameter, not today’s date, so the same function answers ages on any date.

ISO 8601 Duration

You can write an age using the ISO 8601 duration format PnYnMnD, where P introduces the duration and Y, M, and D stand for years, months, and days.

An age of 26 years, 8 months, and 2 days becomes P26Y8M2D; components with a value of zero are omitted, so 26 years and 2 days is P26Y2D. Because years and months are nominal calendar units rather than fixed numbers of days, convert from the years-months-days result rather than from total days.

Note that weeks cannot be combined with years, months, or days in one duration: a week-based duration such as P52W must stand alone.

Month-End Dates and the Clamping Convention

Dates near the end of a month create an important complication that simple borrowing tutorials often overlook. Consider an interval involving dates such as January 31, February 28, March 1, or March 31.

Because the months involved have different lengths, there can be more than one reasonable way to describe the remaining interval in months and days. For this reason, a years-months-days result is best understood as a calendar interval representation, not as a set of fixed-duration units.

Two calculators can agree on the completed age and the total number of elapsed days while still displaying the remaining months and days differently for certain month-end intervals. Different calculators use different rules for handling a shortened month, a missing corresponding day, or an end-of-month boundary.

When comparing calculators, pay attention to whether they use actual calendar month lengths, state how month-end dates are treated, distinguish total elapsed days from a years-months-days representation, and apply the same reference date.

This site’s calculator uses month-end clamping. When an anniversary day does not exist in a shorter month, the anniversary is limited to that month’s last valid day.

For example, with a date of birth of January 31, 2026 and a reference date of February 28, 2026, the result is 0 years, 1 month, 0 days: the one-month anniversary of January 31 falls on February 28 because February 2026 has no 31st day.

On the next day, March 1, 2026, the result becomes 0 years, 1 month, 1 day. The original calendar day stays the anchor, so normal month counting resumes when later months contain that day again.

Calendar Age vs Completed Age vs Total Elapsed Time

The word “age” can describe several related but different measurements. Keeping them separate prevents confusion.

Table 4 · Four Ways to State the Same Span
Measurement What It Means Typical Output
Completed age Number of full birthdays reached 30 years
Calendar age Completed years plus remaining calendar months and days 30 years, 7 months, 15 days
Total elapsed time The interval expressed in a single unit Total days, weeks, hours, or similar
Decimal age An elapsed interval expressed approximately as a decimal number of years 30.63 years

These outputs describe the same general passage of time in different ways, but they are not interchangeable. For example, “30 years, 7 months, and 15 days” is a calendar breakdown.

A total-day result instead counts the complete elapsed interval using days as the unit. A decimal-age result converts elapsed time into an approximate fraction of a year.

Why Dividing Total Days by 365 Is Not an Exact Age Formula

A common shortcut is: Approximate age in years = Total elapsed days ÷ 365. This can provide a rough numerical estimate, but it does not produce an exact calendar age in years, months, and days.

There are two main reasons: calendar years do not all contain 365 days because leap years contain 366, and calendar months vary in length, so a decimal fraction of a year cannot be converted directly into a unique number of calendar months and days.

Using 365.25 or another average-year value can improve some decimal approximations, but the result is still a decimal representation of elapsed time rather than the standard birthday-based calendar age. Dividing total days by 365 or 365.25 drifts about one day every four years, nearly a week by age 30.

If you need to know whether someone is 25 or 26 years old, use the completed-birthday rule. If you need an exact calendar breakdown, calculate actual years, months, and days using calendar dates.

How Leap Years Affect the Age Formula

A leap year adds an extra day to February, giving it 29 days instead of 28. This affects calendar arithmetic whenever an age interval crosses February or a calculation needs to borrow days from that month.

For ordinary age calculations, the important rule is simple: use the actual length of February in the relevant calendar year rather than assuming it always contains 28 days.

The U.S. Naval Observatory states the Gregorian leap-year rule that decides which years add a 29th day in February: a year is a leap year when 4 divides it evenly, except a century year, which must also divide evenly by 400.

A date of birth on February 29 creates an additional edge case in non-leap years because different administrative, legal, or software contexts apply different conventions to the birthday date.

A general-purpose formula should not present February 28 or March 1 as a universal rule for every context. See our guide to how age is calculated for leap year birthdays for a more focused explanation.

Manual Method Facts

Three-column subtraction: write the dates as day / month / year and subtract right to left, days first, then months, then years, like column subtraction.

The two borrowing rules: if days go negative, borrow the previous month’s days and reduce the month by 1. If months go negative, borrow 12 months and reduce the year by 1.

Calendar method vs 30-day method: psychometric testing (for example, Pearson WIAT-III) assumes all months are 30 days. For everything else, use real month lengths. The two methods differ by 1-2 days.

Completed years rule: whole years = the reference year minus the birth year, less one when the birthday is still ahead in the reference year.

The divide-by-365 error: dividing total days by 365 or 365.25 drifts about one day every four years, nearly a week by age 30.

Leap-year rule: divisible by 4, except century years which must also be divisible by 400. The manual method handles this automatically because you borrow real month lengths. The National Institute of Standards and Technology gives the 365.2425-day mean Gregorian year behind the divide-by-365 drift.

How This Guide Compares

Three formula guides rank for the same query, and each one states the formula a little differently. The table that follows shows which one gives you the formula in every form and which one stops at the calculator.

Table 5 · Age Formula Guides Compared
Feature This guide StatsUnlock CalculatorLib OmniCalc
Formula in plain language, notation, and spreadsheet form Yes Yes Not shown Not shown
Borrow-from quiz proving why the borrow month matters Yes Not shown Not shown Not shown
ISO 8601 duration (PnYnMnD) explained Yes Yes Not shown Not shown
Feb 29 birthday rule stated Yes Yes Not shown Yes
Psychometric 30-day method (Pearson WIAT-III) covered Yes Not shown Not shown Not shown
Divide-by-365 drift quantified Yes Yes Not shown Not shown
Calculator built into the page No Yes Yes Yes
Free to read, open to everyone Yes Yes Yes Yes

What this guide does not give you: no calculator is built into the page; this page links to the Age Calculator instead. StatsUnlock, CalculatorLib and OmniCalc each embed one.

No rival guide gives you the formula in plain language, notation, and spreadsheet form in one place, the borrow quiz, the ISO 8601 duration, and the psychometric 30-day method, all covered above.

Sources

  • U.S. Naval Observatory: Leap Years (the leap rule behind the month lengths in the formula)
  • NIST: Time and Frequency from A to Z (the mean Gregorian year behind the divide-by-365 drift)
  • Microsoft Support: Calculate Age (Microsoft’s own age formula, and the DATEDIF unit codes)

Frequently Asked Questions

What is the simplest formula for calculating age?

For completed age in years, subtract the birth year from the reference year. If the birthday has not yet occurred by the reference date, subtract one more year.

What is a reference date in an age calculation?

The reference date is the date on which you want to know someone’s age. It can be today, a past date, or a future date. Age is calculated from the date of birth to that reference date.

Can I calculate age for a past or future date?

Yes. Replace today’s date with the required past or future reference date and apply the same calendar-age rules. For an automatic calculation, use the age on a specific date calculator.

Why can two age calculators show different months or days?

Month lengths are unequal, so certain end-of-month intervals can be represented differently depending on the calendar convention used by the calculator. Two calculators agree on completed years and total elapsed days while decomposing the remaining interval into months and days differently.

Is dividing total days by 365 an accurate way to calculate age?

It can give an approximate decimal age, but it is not an exact formula for calendar age in years, months, and days. Leap years and unequal month lengths make calendar arithmetic different from simply dividing elapsed days by a fixed number.

How is a February 29 birthday handled in a non-leap year?

Calendar calculations must account for the fact that February 29 does not exist in a non-leap year.

The convention used for birthday or administrative purposes can depend on the calculator, organization, jurisdiction, or context, so February 28 or March 1 should not be presented as a universal rule. See our leap year birthday guide for more detail.

How does this site’s calculator render month-end edge cases?

Our calculator uses month-end clamping. When an anniversary day does not exist in a shorter month, the anniversary is limited to that month’s last valid day.

For example, with a date of birth of January 31, 2026 and a reference date of February 28, 2026, the result is 0 years, 1 month, 0 days: the one-month anniversary of January 31 falls on February 28 because February 2026 has no 31st day.

On the next day, March 1, 2026, the result becomes 0 years, 1 month, 1 day. The original calendar day stays the anchor, so normal month counting resumes when later months contain that day again.

How can I express an age as an ISO 8601 duration?

You can write an age using the ISO 8601 duration format PnYnMnD, where P introduces the duration and Y, M, and D stand for years, months, and days.

An age of 26 years, 8 months, and 2 days becomes P26Y8M2D; components with a value of zero are omitted, so 26 years and 2 days is P26Y2D. Because years and months are nominal calendar units rather than fixed numbers of days, convert from the years-months-days result rather than from total days.

Note that weeks cannot be combined with years, months, or days in one duration: a week-based duration such as P52W must stand alone.

Exact Age vs Completed Age vs Running Age: How to tell exact, completed and running age apart.

How to Calculate Age From Date of Birth: The step-by-step method this formula reference sits beside.

What Is Chronological Age: Chronological age defined, and the completed-years rule behind it.

Calendar Age vs Total Days Lived: Total days and calendar age, and why they never match.

Month-End Birthday Age Calculation: The 31st in a short month, and the rule that counts it.

Common Age Calculation Mistakes and How to Verify the Result: Hand calculations go wrong in a few predictable ways, and here is how to catch each one.

Methodology: The counting rules behind each age this site publishes.