Age arithmetic looks trivial and is not, because months and years have unequal lengths. Subtracting two calendar dates directly to get “years and months” produces wrong answers whenever the day-of-month of the birth date falls after the day-of-month of the target date — you have to borrow from the month column, and the amount you borrow depends on how many days the previous month actually had.
Why the naive subtraction fails
Someone born on 30 January, checked on 1 March, is not “1 month and 1 day” old since their last birthday in a naive year-month-day subtraction — the day component goes negative (1 − 30) and has to borrow a full month, and that borrowed month is worth 28, 29, 30 or 31 days depending on which month it is. Get this wrong and ages come out fluctuating by a day depending on which months are involved, which is why so many quick age scripts are subtly buggy.
Total days as the honest number
Because years and months are irregular units, the one figure that is unambiguous is the total elapsed days — a straight difference between two calendar dates with no unit conversion involved. Everything else, including “years and months,” is a human-readable approximation layered on top of that count.
Leap years
A year is not exactly 365 days; the calendar adds a leap day roughly every four years to keep pace with the actual solar year. Someone born on 29 February has a real birthday only once every four years on the standard calendar — most systems, including this one, treat 1 March as their observed birthday in non-leap years, though there is no universal convention and some jurisdictions specify 28 February instead for legal purposes such as the age of majority.
Where exact age actually matters
- Legal eligibility — voting, driving, purchasing age-restricted goods — is defined by exact elapsed time, not a rounded figure.
- Insurance premiums and actuarial tables are often banded by age in a way sensitive to which side of a birthday a person falls.
- Developmental and medical assessments in young children are frequently expressed in months rather than years, because a few months matters proportionally more early in life.