Adding Months and Years to a Date

What "one month after 31 January" means, why adding months in steps can give a different answer, and how spreadsheets and programming languages disagree.

Key facts

  • A month lasts 28 to 31 days, so "one month after 31 January" has no exact answer until a rule is stated.
  • DateUtils clamps to the last day of the target month: 31 January 2025 plus 1 month is 28 February 2025, and 31 January 2024 plus 1 month is 29 February 2024.
  • Adding in steps is not the same as adding at once: 31 January 2025 plus 1 month plus 1 month is 28 March 2025, but 31 January 2025 plus 2 months is 31 March 2025.
  • Month addition does not undo itself: 28 February 2025 minus 1 month is 28 January 2025, not 31 January.
  • Adding days and weeks is exact, because a week is always 7 calendar days.

Why a month is not a fixed number of days

A month is a calendar unit, not a duration. February has 28 days in a common year and 29 in a leap year; the other eleven months have 30 or 31. The Gregorian calendar averages 365.2425 days a year, or 30.4369 days a month, and no individual month ever measures that. "Add one month" therefore cannot be rewritten as "add 30 days" without changing the answer.

Because the target month can be shorter than the starting day, any tool that adds months has to say what happens when the date it wants does not exist.

Clamping and overflow

Clamping to the last day of the month

Clamping keeps the same day of the month, and when that day is missing it falls back to the last day that does exist. This is the rule DateUtils uses, and it is set out in the DateUtils calculation methodology: the result never spills into the following month.

So 31 January 2025 plus 1 month is Friday 28 February 2025, while 31 January 2024 plus 1 month is Thursday 29 February 2024. The difference between those two answers is entirely a matter of whether the target February has 29 days.

Adding one month to a late-month date, clamped to the last day of the target month
Start dateResult in a leap year (2024)Result in a common year (2025)
29 January29 February 202428 February 2025
30 January29 February 202428 February 2025
31 January29 February 202428 February 2025
31 March30 April 202430 April 2025
31 May30 June 202430 June 2025
31 August30 September 202430 September 2025
31 October30 November 202430 November 2025

Month lengths behind those results are listed in the DateUtils days in month tool. The clamping rule is also the one used by EDATE in Excel and Google Sheets.

Overflow into the next month

Overflow instead carries the surplus days forward. The JavaScript Date object behaves this way: calling setMonth on 31 January 2025 produces 3 March 2025, and on 31 January 2024 produces 2 March 2024, because 31 February is three days past the end of a 28-day February and two days past the end of a 29-day one.

Neither rule is wrong; they answer different questions. Clamping keeps the result inside the target month, while overflow treats the missing days as a carry into the following month. The practical problem is that the same instruction can give two different dates depending on which tool applies it When a date moves between a spreadsheet, a program and a contract, check which rule each one applies.

Adding in steps is not the same as adding at once

Because clamping forgets the original day of the month, repeated additions drift. Starting from Friday 31 January 2025, adding 1 month and then 1 month gives 28 February 2025 and then 28 March 2025. Adding 2 months in a single step gives 31 March 2025. The first route is 56 days, the second 59 days, which the DateUtils date difference calculator will confirm for you.

The same applies to years. Under the DateUtils rule, 29 February 2024 plus 1 year is 28 February 2025, because 29 February does not exist in a common year. Under an overflow rule the same instruction gives 1 March 2025. The leap years reference covers the rule in full.

Subtracting months is not the inverse of adding

28 February 2025 minus 1 month is 28 January 2025, not 31 January, because subtracting one month also clamps. Working backwards does not recover the date you started from.

Month arithmetic does not keep the day of the week either. 31 March 2024 was a Sunday, yet one month earlier is 29 February 2024, a Thursday. If a schedule must land on a particular weekday, count days or weeks instead of months.

Days and weeks are exact

A calendar day is one step on the calendar and a week is always 7 of them, so adding either needs no convention at all. 10 days after 31 January 2025 is 10 February 2025, and 2 weeks after the same date is 14 February 2025, whatever the month length. The DateUtils add days tool needs no end-of-month handling for that reason.

Where a duration must be exact, reversible and open to no argument, express it in days. Forty-five days after 1 January 2025 is 15 February 2025, in every year, under every convention.

End-of-month conventions

Some contracts, leases and financial schedules treat a month end as a property rather than a date. On that reading, 31 January plus 1 month is 28 or 29 February, and a further month is 31 March, so the series stays at the end of each month. Spreadsheets offer this as a separate function, EOMONTH, alongside the clamping EDATE.

DateUtils does not carry an end-of-month property forward. The clamp is applied once, to the result, and the original day of the month is not remembered: after 31 January 2025 plus 1 month, the next month gives 28 March 2025 rather than 31 March. This is worth knowing if you are porting a schedule between a spreadsheet and a tool.

Choosing a rule

  • Contracts, notice periods and tenancies. Read the governing wording, and check whether it defines a month as a calendar month, a period of 30 days, or an end-of-month date. The three give different deadlines from the same starting point.
  • Recurring schedules such as rent, invoices or payroll runs. Fix one convention and record it, and decide whether each run measures from the previous result or from the original start date. Measuring from the previous result drifts; measuring from the original does not.
  • Anything that must be auditable. Store the interval in days, not months, and check it with the date difference calculator. A number of days has only one meaning.
  • Ages and birthdays. The same clamping rule governs a 29 February birthday, which is observed on 28 February in a common year. The DateUtils age calculator applies it that way.

DateUtils works with proleptic Gregorian dates from year 1 to year 9999, and rejects a result that falls outside that range. Adding 1 year to a date in year 9999 therefore produces no answer in the tool, rather than a date it cannot represent.