Age Calculator Formula

Understand the math behind the age calculator. Each variable explained with a worked example.

Formulas Used

Age in Years

age_years = floor(total_months / 12)

Additional Months

age_months_remainder = total_months - floor(total_months / 12) * 12

Total Months Lived

total_months_lived = total_months

Variables

VariableDescriptionDefault
birth_yearBirth Year1990
birth_monthBirth Month (1-12)6
current_yearCurrent Year2026
current_monthCurrent Month (1-12)3
total_monthsDerived value= (current_year - birth_year) * 12 + (current_month - birth_month)calculated

How It Works

How to Calculate Age

Subtract your birth date from the current date, counting full years and remaining months.

Formula

Total Months = (Current Year - Birth Year) x 12 + (Current Month - Birth Month)

Age in Years = floor(Total Months / 12)

Worked Example

Born June 1990, current date March 2026.

birth_year = 1990birth_month = 6current_year = 2026current_month = 3
  1. 01Total months = (2026 - 1990) x 12 + (3 - 6) = 432 - 3 = 429
  2. 02Age in years = floor(429 / 12) = 35
  3. 03Remaining months = 429 - 35 x 12 = 9
  4. 04You are 35 years and 9 months old

Ready to run the numbers?

Open Age Calculator