How to Use This Tool
Pick a starting date, choose add or subtract, and fill in any mix of years, months, weeks and days. The working underneath shows each step in order, because the order changes the answer.
Days are exact, months are a convention
Adding days is unambiguous: 30 days after any date is 30 days later, and subtracting 30 brings you back to exactly where you were. Weeks are just days in sevens, so they behave the same way.
Months do not, because they are different lengths. Asked for one month after 31 January, every date library gives 28 February, because 31 February does not exist and the convention is to clamp to the last day of the target month. Ask for one month before 28 February and you get 28 January.
So add one month and subtract one month, and you land three days from where you started. That is not a bug in any particular library — it is the arithmetic. There is no correct answer, so everyone picked the same reasonable one.
Why this matters for anything monthly
A subscription that starts on 31 January bills on 28 February. What happens in March depends on a design decision the software made:
- Anchor on the original date. March bills on the 31st, April on the 30th, May on the 31st. The date wobbles but always returns to the intended day.
- Anchor on the last billed date. March bills on the 28th, and every month afterwards is the 28th. The subscription has permanently moved.
Both are defensible and they diverge permanently after the first February. If you are building something that recurs monthly, pick one deliberately and write it down — this is the sort of thing that gets discovered a year later by a confused customer.
The order of operations is part of the answer
Because clamping loses information, applying the parts in a different order can give a different date. The near-universal convention, and the one used here, is years, then months, then days — the coarse units first, so any clamping happens before the fine adjustment rather than after it.
Worth knowing if you are comparing this against a spreadsheet or a database: most follow the same order, but not all, and the disagreements only show up at month ends.
Working days
Ticking working days counts only Monday to Friday, so five working days from a Monday is the following Monday. Public holidays are not included, because they differ by country, by region within a country, and by year — a built-in list would be wrong somewhere without telling you where.
For contractual deadlines, check the wording carefully: "within 10 days" and "within 10 business days" are different, and some jurisdictions exclude the start date while others include it.
