Adding one month to 31 January has no right answer. The 31st of February does not exist, so a library either clamps to the last day of February or rolls forward into March — and both behaviours are shipped, in widely used software, today.
Every other oddity in calendar arithmetic has the same shape. The units are not uniform, so the operations are conventions rather than sums.
Why do month differences disagree?
Because the answer depends on whether you count completed months or calendar boundaries crossed. From 31 January to 1 March is one month and one day by one reading and two calendar months by another.
The convention most tools use is completed months plus remaining days, which matches how people describe an age. It is also the reason a difference of "one month" can be 28 days or 31 depending on which month it was.
For anything that must be exact — a billing period, a notice period, a legal deadline — counting days is unambiguous where counting months is not. That is why contracts specify thirty days rather than one month when they mean it.
What is the leap year rule?
Three clauses, and the last one catches people out.
| Rule | Effect |
|---|---|
| Divisible by 4 | leap year |
| Unless divisible by 100 | not a leap year |
| Unless also divisible by 400 | leap year after all |
So 2000 was a leap year and 1900 was not, and 2100 will not be. Software written between those two dates could get away with checking only the first clause, which is why the exception is less familiar than it should be.
The correction exists because the solar year is not quite 365.25 days. Adding a day every four years overshoots slightly, and skipping three of those additions every four centuries brings it back.
Which week is week 1?
The one containing the first Thursday of the year — equivalently, the week containing 4 January. That definition comes from the international standard and it means the first days of January frequently belong to the last week of the previous year.
It also means a year has either 52 or 53 weeks, and which one is not obvious from the year alone. A business reporting on weeks needs to know which of the two it is dealing with before comparing year against year.
Weeks in that standard start on Monday. Other conventions start on Sunday and number weeks differently, so a week number is meaningless without knowing which system produced it.
How do you count working days?
By counting weekdays and subtracting holidays, which is the easy half. The hard half is that holidays are jurisdictional, they move, and some of them move according to rules that are not arithmetic.
Any calculation involving business days therefore needs a holiday list for one place and one year, and a result computed for one country is wrong for another. Weekend days differ too — the working week is not Monday to Friday everywhere.
Where a date range crosses two systems, the safest approach is to count in plain days and apply the working-day question separately at each end.
What does an overlap calculation answer?
How many days two periods share, which is a different question from how far apart they are. It is the calculation behind checking whether two bookings clash, whether two employment periods overlap, or how much of a subscription falls inside a tax year.
The edge case is whether the end date is included. A range from the 1st to the 5th is four days or five depending on whether the last day counts, and both conventions are in use — inclusive counting for holidays and stays, exclusive for durations.
Stating which one is being used is worth more than picking the right one. Nearly every disagreement about a date range is this question rather than an arithmetic error.
Why is a year not 365 days of work?
Because the useful unit for planning is rarely the calendar one. A year holds about 261 weekdays before holidays, and subtracting public holidays and leave brings a typical working year closer to 220 days.
That gap is why capacity plans built on calendar months overrun. A month is not four weeks — it averages about 4.35 — and a quarter is not thirteen weeks in every case, so a schedule assuming either drifts by several days across a year.
Questions people ask
How many days in a year? 365, or 366 in a leap year. Some financial conventions use 360 for interest.
What is the day of the year? A number from 1 to 365 or 366, counting from 1 January. It is a compact way to store a date within a known year.
Do quarters always start in January? Calendar quarters do. Fiscal quarters start wherever the organisation’s year does.
Why does my date shift by a day? Almost always a time zone applied where none was intended. A date with no time is not an instant.
Count in the unit the question is asked in. How many months between dates and the date range duration calculator handle the differences, days in year, day of year and date from day of year cover the within-year questions, week number to date, the weekday counter and weekend days between dates handle weeks, date range overlap answers the clash question, days ago works backwards, and the quarter date range calculator gives the boundaries.