Calculate Age: 8 Simple Rules to Get It Exactly Right
To calculate age correctly you count whole years first, then whole months, then leftover days. Dividing a day count by 365 looks like a shortcut to calculate age, but it drifts, and the drift is exactly why two websites can give you two different answers for the same birthday.
Here is the thing. The way to calculate age is old school long subtraction, and every rule below exists to stop one specific mistake. Read them in order once, then keep the lookup tables for later.
Why it is harder to calculate age than it looks
Months have 28, 29, 30 or 31 days. Years have 365 or 366. A person who says they are 40 years, 6 months and 26 days old is describing a position on the calendar, not a fixed number of seconds. So any way to calculate age that turns the gap into one big number and then divides will land close, but not always on the right side of a birthday.
8 rules that stop age from drifting
- Count whole years first when you calculate age. Take the target year minus the birth year, then lower it by one if the birthday has not happened yet this year. Rationale: a person is never 25 until the 25th birthday has passed.
- Then count whole months. After the last birthday, count how many full months have passed. Rationale: months are the natural unit between birthdays.
- Then count leftover days. Whatever remains after the last full month is the day count. Rationale: this lets you calculate age in the way people say it aloud.
- Borrow days from the month before the target date. If the day difference is negative, add the length of the previous month, and take one from the month count. Borrowing from February gives 28 or 29, never a flat 30. Rationale: to calculate age you are walking back through real calendar months.
- Borrow months from the years. If the month difference is negative, add 12 months and take one from the years. Rationale: this is the same carry you use in long subtraction.
- Treat the birth date as day zero. The day you were born is not day one. Counting that way gives one extra day compared with an exclusive count. Rationale: it matches how birthdays work, since you turn 1 exactly 365 or 366 days after birth.
- Handle month end birthdays on purpose. If you were born on the 31st and the previous month has 30 days, simple borrowing can leave a negative day count. Pick a convention and state it. Rationale: this is the main reason two correct tools can differ by a day.
- Pick one time zone for the target date. Use the local date of the person, not a UTC date. Rationale: to calculate age near midnight, the date itself can change with the zone, and so can the age.
Days, hours, minutes and seconds between two dates are exact counts. Months and years are not. If you need a decimal such as 40.57 years, say that it is an average based on 365.25 days per year.
Enter a date of birth and a target date to calculate age, and the tool walks the calendar for you, then shows totals in days, hours and weeks. Everything runs in your browser.
Open the Age CalculatorFour dates worked out by hand
Each row below follows rules 1 to 5. Check them against your own calculator and you will see the pattern. The final column uses the exact day count between the two dates.
| Born | On | Raw difference | After borrowing | Total days |
|---|---|---|---|---|
1985-11-15 | 2026-06-10 | 41 y, minus 5 m, minus 5 d | 40 y, 6 m, 26 d | 14,817 |
1999-05-20 | 2024-05-20 | 25 y, 0 m, 0 d | 25 y, 0 m, 0 d | 9,132 |
2004-12-31 | 2025-01-01 | 21 y, minus 11 m, minus 30 d | 20 y, 0 m, 1 d | 7,306 |
2000-02-29 | 2023-03-01 | 23 y, 1 m, minus 28 d | 23 y, 0 m, 0 d | 8,401 |
Look at the first row to see how to calculate age with two borrows. The day difference is minus 5, so borrow the length of May, which is 31 days, and the day count becomes 26. The month count drops from minus 5 to minus 6, so borrow 12 months, which gives 6 months and takes one year off. The answer is 40 years, 6 months and 26 days.
The third row is the cleanest example of a double borrow. A person born on New Year Eve is exactly 20 years old on the last day of 2024, and one day older the next morning, even though the calendar year changed twice in the raw subtraction.
Why dividing by 365 fails
The quick way to calculate age is to subtract the dates, divide the days by 365 or 365.25, and round down. It works most days. It fails on birthdays, which are the days people care about.
| Method | Calculation | Result | Floor | Correct? |
|---|---|---|---|---|
| Exact calendar walk | 25 whole years | 25 y, 0 m, 0 d | 25 | Yes |
| Divide by 365 | 9,131 ÷ 365 | 25.016 | 25 | Yes, by luck |
| Divide by 365.25 | 9,131 ÷ 365.25 | 24.9993 | 24 | No, one year short |
| Divide by 365.2425 | 9,131 ÷ 365.2425 | 24.9998 | 24 | No, one year short |
Between those two dates there are 25 years and 6 leap days, which is 9,131 days. A 25 year span at 365.25 days would be 9,131.25 days, so the division falls a quarter day short. The person turned 25 that morning, but the formula says 24 point 9993. This is the classic reason a rounding based tool fails to calculate age correctly on a birthday.
For legal ages such as 18 or 21, rely on the calendar walk. Decimal years are fine for a rough statistic, not for a cutoff.
The calendar walk in plain JavaScript
function calcAge(dob, on) {
let y = on.getFullYear() - dob.getFullYear();
let m = on.getMonth() - dob.getMonth();
let d = on.getDate() - dob.getDate();
if (d < 0) {
m--;
// day 0 of a month is the last day of the month before
d += new Date(on.getFullYear(), on.getMonth(), 0).getDate();
}
if (m < 0) { y--; m += 12; }
return { y, m, d };
}
// month end birthdays (rule 7) need an extra convention
Leap day births: which date counts
Someone born on 29 February has a real birthday only once every four years, and sometimes not even then. The century rule makes 1900 and 2100 common years, while 2000 was a leap year. So which day do they turn a year older in a common year?
| Convention | Anniversary in a common year | Used by | Effect on age |
|---|---|---|---|
| Roll forward | 1 March | United Kingdom and Taiwan for legal purposes | Turns one year older on 1 March |
| Roll back | 28 February | Some other places and many personal habits | Turns one year older on 28 February |
A calendar walk to calculate age that builds a date from year, month and day will roll 29 February into 1 March in a common year, which matches the first convention. For a legal question, check the rule in the place that matters. This varies, and a calculator cannot settle it for you.
The 20th birthday fell on 31 December 2024, so the person is exactly one day past 20. The raw subtraction gives 21 years with negative months and days, and the two borrows bring it back to 20 years, 0 months and 1 day.
Lookup table: age in days at common milestones
Handy for planning and trivia. The figures are for a person born on 10 June 2001, so they include the leap days that fell in that span.
| Age | Date reached | Days lived | Whole weeks | Hours |
|---|---|---|---|---|
| 18 | 2019-06-10 | 6,574 | 939 | 157,776 |
| 21 | 2022-06-10 | 7,670 | 1,095 | 184,080 |
| 30 | 2031-06-10 | 10,957 | 1,565 | 262,968 |
| 50 | 2051-06-10 | 18,262 | 2,608 | 438,288 |
The Age Calculator also shows the next birthday countdown, a count of heartbeats at 72 per minute and a count of lunar cycles at 29.53 days each. Treat those as scale figures, since real heart rates vary. For a plain gap between two dates that are not a birthday, use the Date Difference Calculator.
Run this checklist before you trust the result
Where to go next
If you want to know how long until an event rather than how long since one, try the Days Until Date Counter. For payroll or deadlines that skip weekends, the Working Days Calculator is the better fit.
Questions people ask when they calculate age
How do I calculate age from date of birth?
Subtract the birth year from the target year, lower it by one if the birthday has not yet occurred, then count the full months and leftover days after that birthday.
Why does my result differ when two calculators calculate age?
The usual causes are inclusive versus exclusive day counting, a different time zone for the target date, and different handling of month end birthdays. Check those three first.
Is 365.25 the right number to divide by?
It is a good average for decimal years, but it is not exact on a birthday. Use the calendar walk when the result decides something.
When does a leap day baby turn a year older?
It depends on the rule in force. In the United Kingdom and Taiwan the legal birthday in a common year is 1 March, while personal habits often use 28 February.
How many days old am I?
To calculate age in days, subtract your birth date from today. The exact day count is the same in every tool, since days have a fixed length. Only months and years are averages.
Does the day I was born count as day one?
A calendar age counts it as day zero. Counting it as day one adds a day and makes the result disagree with a birthday.
Sources: Wikipedia: Leap year, including leap day birthdays and the Gregorian rule
