convert · 6 min read

How to count the days between two dates

Two people count the same fortnight and get 13, 14 and 15. All three are defensible, which is the problem.

Counting days sounds like the least ambiguous thing in this section, and it is where the most disagreements start — because dates are a human calendar rather than a number line, and the calendar has been patched by committee for two thousand years.

The off-by-one, and why nobody is wrong

From 1 March to 3 March. Two days, or three?

Two, if you are measuring the gap. Subtract one date from the other and that is the answer, and it is what every date library returns.

Three, if you are counting the days covered. A hotel booking from the 1st to the 3rd is three days of your holiday. A notice period of three days starting on the 1st ends on the 3rd.

Both are correct for their question. The confusion only becomes expensive in contracts, deadlines and invoices, where it is worth writing which you meant rather than assuming the reader shares your convention.

Working days

Removing weekends is arithmetic and any tool can do it. Removing holidays is not, and this is the honest limit of every business-day calculator.

Public holidays differ by country, by region within a country — a Scottish bank holiday is not an English one — and by year, since several move with Easter or with the lunar calendar. Some are declared with weeks of notice.

So a calculator that offers business days without asking where you are is counting weekends only. That is often what you want, and it is worth knowing that is what you are getting.

Weekends are not universal either. Much of the Middle East treats Friday and Saturday as the weekend, and a few countries use Thursday and Friday.

Adding months is not adding days

Three months after 31 January.

31 April does not exist, so something has to give. Most systems clamp to the last valid day of the target month and answer 30 April. Others roll forward to 1 May. Both are defensible and they are one day apart, which is exactly the gap that matters on a payment deadline.

A consequence people find genuinely surprising: adding one month twice can differ from adding two months. 31 January plus a month is 28 February; plus another month is 28 March. 31 January plus two months is 31 March. Three days apart, from the same starting point.

This is not a bug in anyone's software. It is what happens when a unit does not have a fixed length.

Age is counted differently again

Your age is not elapsed days divided by 365, and not by 365.25 either. It is the number of times your birthday has passed — a count of calendar years, which is why it changes on a specific date rather than gradually.

The 365.25 approximation drifts, and it does not match what anyone means. For legal purposes, most jurisdictions define reaching an age as the start of the birthday itself, with a handful of exceptions that use the day before.

An age calculator should count years, months and days rather than dividing anything.

Time zones make some days short

A day is not always 24 hours. On the day clocks go forward it is 23; when they go back it is 25. So the number of hours between two dates and the number of days between them can disagree in a way that looks like an error.

If two dates are in different zones there is a further question of whose day you are counting. Which is a problem in its own right.

The leap year that never happened

Excel stores dates as serial numbers counting from the beginning of 1900, and it treats 1900 as a leap year. It was not — century years are only leap years when divisible by 400, and 1900 is not.

So Excel accepts 29 February 1900, a date that never existed. The bug was inherited deliberately from Lotus 1-2-3 for compatibility and has been kept ever since, because fixing it would shift every stored date by a day.

The consequence is that Excel's serial numbers before 1 March 1900 are off by one against every other system. It matters almost never and it is worth knowing about when genealogy data will not line up.

The short version

Decide whether you are measuring a gap or counting days covered, and say which. A date calculator that shows both removes the argument. Expect business days to mean "minus weekends" unless holidays were declared. And never treat a month as a fixed number of days.

Questions

Do I count both the start and the end date?

It depends what you are counting, and this is the off-by-one everyone meets. The difference between two dates is exclusive: 1 March to 3 March is two days. The number of days a period covers is inclusive: a booking from the 1st to the 3rd is three days. Neither is wrong; contracts and hotels routinely mean different things by the same phrase.

How do I count working days between two dates?

Remove the weekends, then remove public holidays — and the second half is why no calculator can give a universally right answer. Holidays differ by country, by region within a country, and by year. Any tool offering "business days" without asking where you are is counting weekends only.

What is three months after 31 January?

There is no single correct answer. 30 April is the usual convention, because 31 April does not exist and most systems clamp to the last valid day. Others roll forward to 1 May. Adding months is not arithmetic on a number line, which is why adding one month twice can differ from adding two months.

Why is my age not the number of days divided by 365?

Because years vary. Age is counted in calendar years — how many times your birthday has passed — not in elapsed days. Dividing by 365 drifts by roughly a day every four years, and dividing by 365.25 is closer but still not what anyone means by an age.

Why does Excel show a date one day out?

Excel treats 1900 as a leap year, so it accepts a 29 February 1900 that never existed. The bug was deliberately kept for compatibility with Lotus 1-2-3 and is still there. Every date serial before 1 March 1900 is off by one, which almost never matters and is occasionally maddening.

Tools from this guide