Count completed years first
Begin with the comparison year minus the birth year. Construct that year's anniversary and check whether it falls after the comparison date. If it does, subtract one year. For example, someone born on October 20 has not completed the next year of age on October 19. A February 29 birthday needs the selected non-leap convention before this comparison is made.
Then count completed months
Use the completed-year anniversary as the month anchor. Advance by whole calendar months without passing the comparison date, clamping a day that does not exist to the target month's last day. January 31 advanced by one month in 2024 becomes February 29; advanced by two months from the original anchor becomes March 31. This preserves month-end intent instead of chaining a shortened February date into every later month.
Count the remaining days
After the largest valid month anchor is found, count civil-date boundaries from that anchor to the comparison date. Date-only values are represented at UTC for this subtraction, so a local daylight-saving change cannot create a 23- or 25-hour 'day' in the result. The remainder is always smaller than the next completed calendar month, although it can be 28, 29, 30, or 31 days depending on the anchor.
Keep totals separate
Total elapsed days are calculated directly between the birth date and comparison date. Whole weeks are total days divided by seven with a day remainder. Completed months are completed years multiplied by twelve plus the remaining completed months. These totals are not interchangeable: 13,149 days may be useful for a record, while 36 years, 0 months, and 1 day is the human calendar description.
Work through a month-end example
For January 31, 2024 through March 30, 2024, zero full years are complete. The one-month anchor is February 29. A two-month anchor would be March 31, which is after the comparison date, so it is not complete. The remainder from February 29 through March 30 is 30 days. The reported calendar interval is therefore 0 years, 1 month, and 30 days, while the separately reported elapsed total is 59 days.
Validate surprising results
First confirm that the two fields were not reversed and that both use the intended Gregorian dates. Next inspect the displayed year and month anchors; they make a month-end clamp visible. For a February 29 birth, confirm the selected February 28 or March 1 convention. If an institution applies a legal or contractual age rule, use its stated method rather than assuming general calendar arithmetic controls eligibility.