Skip to content

How to Calculate Age in Years, Months, and Days

4 min read

The right way to compute exact age from a date of birth, including the leap-year edge case that breaks naive subtraction.

"Current year minus birth year" works fine. Until someone hasn't had their birthday yet, and you're off by one. Here's the method that always lands on the right number.

The algorithm

  • Start with years = current year minus birth year.
  • If today's month is before the birth month, subtract 1.
  • If it's the same month but today's day is before the birth day, subtract 1.
  • Months and days are the leftovers, normalized so days never go negative.

The Feb 29 edge case

Anyone born on February 29 only gets a real birthday every four years. Conventions vary. In the US they're usually treated as aging on March 1 in non-leap years; in the UK, on February 28. Most software just picks one and documents it. Our Age Calculator follows the US convention.

Beyond age: exact differences

For any two dates, the Date Difference Calculator uses the same logic to return years, months, weeks, and days. For a future birthday or milestone, try the Days Until Calculator.

More from the blog