What happens when you add a month to January 31?
Decide what adding one month means when the target month has no 31st.
Try the experimentWhat you’ll learn Compare clamping, rolling forward and rejecting an unavailable day, and see why repeated clamping can drift.
Month-end policy
Where does January 31 land?
Compare a common year with a leap year, then change the rule for the missing day.
February 28, 2025
- StartJanuary 31, 2025
- February endsFebruary 28, 2025
- Chosen resultFebruary 28, 2025
February has 28 days in this year. The requested 31st is 3 days beyond its last day.
Saved reading
Schedule an end-of-month report
- Inputs
- The first report was January 31, 2025, then the February copy was sent on February 28.
- Reasoning
- If the instruction is “last day of each month,” derive each month’s end independently. Adding a month to the last sent date is a different operation.
- What the result means
- March 31 is correct for the report. Repeatedly adding to February 28 would instead give March 28.
Move to February before handling the missing day
A common February ends on the 28th. Clamping chooses that end. An overflow rule preserves the three excess numbers, walking March 1, 2 and 3. Rejecting returns no date. February 29 exists in 2024 but not in 2100, even though both years divide by four.
Ask what must be preserved
If a report is due on the final day, the anchor is month-end and March must end at March 31. Starting a new calculation from the clamped February 28 preserves the number 28 instead. Recalculate recurrence from the original intent, not just the preceding output.
Test the service, not the phrase
Calendar APIs use concrete overflow settings; calendars and contracts may select a different policy. Record what a system actually does for January 31 and for the following cycle. When there is no agreed rule, a rejection is useful because it prevents somebody from silently moving a deadline.
Sources and scope
- TC39 · Calendar dates and date arithmetic — An example of constrain and reject overflow rules.
- U.S. Naval Observatory · Introduction to calendars — Gregorian leap rule and month lengths.
- NASA Goddard · Calendars and their history — Gregorian calendar reference.
These are stated teaching policies, not a legal deadline recommendation. Add & Subtract Dates uses clamping for a missing day.