How Date Calculations Work
Counting days sounds simple until you meet months of different lengths, leap years and the question of whether to count both ends. Here is how the date calculators handle each issue.
Day numbers make everything exact
Internally, each date is turned into a serial number — the count of days since a fixed starting point. Subtracting two serial numbers gives the exact number of days between them, and adding days to a serial number and converting back gives an exact date. Month lengths and leap years are built into the conversion, so they never need special handling afterwards.
Leap years
- Divisible by 4 → leap year (2028)
- but divisible by 100 → not a leap year (2100)
- but divisible by 400 → leap year (2000)
This Gregorian rule keeps the calendar aligned with the seasons to within about one day in 3,000 years or so. Dates before the calendar reform of 1582 are calculated as if the rule had always applied (the “proleptic” Gregorian calendar).
Adding months
Adding one month to 31 January has no perfect answer, because 31 February does not exist. The common convention — used by most spreadsheets and programming libraries — is to clamp to the last day of the month: 31 Jan + 1 month = 28 Feb (or 29 in a leap year). As a result, adding one month twice can differ from adding two months at once, and years and months are applied before weeks and days.
Inclusive vs exclusive counting
A hotel stay from 10 to 14 March
- Nights: 14 − 10 = 4 (exclusive)
- Days you are there: 5 (inclusive of both ends)
Both answers are right — they answer different questions.
Elapsed time is exclusive (the default in the days between dates calculator); counting calendar days of an event is inclusive.
Years, months and days
“2 years, 3 months and 5 days” is computed by stepping whole years, then whole months, then counting leftover days. Because months vary in length, two spans with the same number of days can have different year-month-day descriptions.
ISO week numbers
ISO 8601 weeks start on Monday, and week 1 is the week containing the year’s first Thursday. So 1 January can fall in week 52 or 53 of the previous year, and a year has either 52 or 53 weeks.
Time zones and daylight saving
The calendar calculators work with dates only, so time zones and daylight saving do not affect them. Tools that use the current moment — the countdown, timer and “today” defaults — read your device’s local clock. A day that contains a daylight-saving change has 23 or 25 hours in local time.