Home / Age guides / Guide: how age is calculated

How Age Is Calculated

How to work out an age by hand, why leap day birthdays and East Asian counting differ, and formulas for Excel, SQL and code.

The short answer

Age in years is the number of birthdays a person has had. Subtract the birth year from the current year, and subtract one if this year's birthday has not happened yet. The age calculator does this, and also gives the months and days.

By hand

  1. Write the two dates as year, month and day, with the birth date first.
  2. Subtract the day. If the result is negative, borrow the length of the previous month and take one month off.
  3. Subtract the month. If the result is negative, borrow 12 months and take one year off.
  4. Subtract the year.

For 15 January 2000 and 20 March 2025: days 20 - 15 = 5, months 3 - 1 = 2, years 2025 - 2000 = 25. The age is 25 years, 2 months and 5 days.

Leap day birthdays

A person born on 29 February has a real birthday only in leap years. In other years, some countries and organisations treat 28 February as the birthday, and others 1 March. The rule matters when someone reaches a legal age on a leap day birthday. The age calculator lets you choose, so check the rule that applies to you.

International and East Asian age

Almost everywhere, age is counted the international way: 0 at birth, and one more on each birthday. Traditional East Asian age counting gave a newborn the age of 1 and added a year at each New Year, so a person could be one or two years older than their international age. South Korea moved to the international way for legal and administrative purposes in June 2023, though the older style is still used socially by some people.

Excel and Google Sheets

=DATEDIF(A1,TODAY(),"y")     ' complete years
=DATEDIF(A1,TODAY(),"ym")    ' months after the last birthday
=DATEDIF(A1,TODAY(),"d")     ' total days
=INT(YEARFRAC(A1,TODAY()))   ' complete years, alternative

The "md" unit of DATEDIF, for the days after the last month, is known to give wrong results in some cases, so avoid it.

SQL

-- MySQL
SELECT TIMESTAMPDIFF(YEAR, dob, CURDATE()) AS age FROM people;

-- PostgreSQL
SELECT EXTRACT(YEAR FROM AGE(dob)) AS age FROM people;

JavaScript, Python and PHP

// JavaScript
function age(dob, on = new Date()) {
  let y = on.getFullYear() - dob.getFullYear();
  const m = on.getMonth() - dob.getMonth();
  if (m < 0 || (m === 0 && on.getDate() < dob.getDate())) y--;
  return y;
}

# Python
from dateutil.relativedelta import relativedelta
age = relativedelta(date.today(), dob).years

// PHP
$age = (new DateTime($dob))->diff(new DateTime('today'))->y;

Time of birth and time zones

Age is counted in whole days. The time of day of the birth, and the time zone, are not used, so a person turns a year older at the start of the birthday. For the exact time between two moments, use a date-time library.

Other ways of expressing age

Related tools

For any two dates, use date difference, and read the guide to days between dates.

Work out an age now. Enter a date of birth and get the age in years, months and days.

Open the age calculator

Frequently asked questions

How do I calculate age from a date of birth?

Subtract the birth year from the current year, and subtract one if the birthday has not happened yet this year. For months and days, borrow from the previous month and year as in a subtraction.

How is age calculated for a leap day birthday?

In years without 29 February, some places use 28 February and others use 1 March. The age calculator lets you choose.

What is the formula for age in Excel?

Use =DATEDIF(A1,TODAY(),"y") for complete years, with the date of birth in A1.

Is Korean age different from international age?

Traditional Korean age counted a newborn as 1 and added a year at New Year. South Korea moved to international age for legal and administrative use in June 2023.