All guides

How to add or subtract days, months and years from a date

Last updated:

Adding time to a date sounds simple until you hit an edge case: what happens when you add a month to January 31st, a date that doesn't exist in February?

The order of operations matters

A correct date calculator applies years and months first, then days. This matters because month-end dates need special handling: if the target month is shorter, the day is capped at that month's last day rather than overflowing into the next month.

Worked example: the January 31st problem

Adding 1 month to January 31, 2026 gives February 28, 2026 — not March 3rd. Since 2026 isn't a leap year, February only has 28 days, so the day component is capped there instead of spilling into March. This lands on a Saturday.

Worked example: combining days, months and years

Adding 1 year, 2 months and 10 days to July 18, 2026 gives September 28, 2027 (a Tuesday). Adding 90 days instead gives October 16, 2026 (a Friday). Subtracting 45 days from July 18, 2026 gives June 3, 2026.

Common mistakes

  • Assuming "add a month" always moves the day number forward by the same amount — near month-end dates, it doesn't.
  • Adding days and months in the wrong order by hand — doing days first can land on a different date than doing months first when a month boundary is involved.

Use the Date Calculator to add or subtract any combination of days, months and years; for counting the days between two dates instead, see Days Until Date Calculator.