How to Count Days Between Two Dates (End Included?)
How many days lie between two dates, why counting both ends gives one more, and how weeks, months and leap years change the answer.
In this article
How many days are there between two dates? The answer depends on one small choice: whether the last day counts. This guide shows the difference with real dates, explains why counting both ends gives one more, and covers weeks, months, leap years and the usual mistakes.
Two ways to count
From the 1st of January to the 10th of January, there are 9 days between the dates: you move forward nine times to get from the 1st to the 10th. But if you are asked how many days a booking from the 1st to the 10th covers, and both the first and last days are used, the answer is 10.
Neither answer is wrong. They answer different questions. The first is the gap between two dates. The second counts every calendar day from the start to the end, with both included. Our calculator gives the gap by default, and adds one day when you tick the option to count the end date.
Why the second count is one higher
This is a classic counting trap, known to programmers as an off-by-one error. Wikipedia's article uses a fence: a straight fence 30 feet long with posts 3 feet apart has 10 sections, but it needs 11 posts, because a fence with n sections has n + 1 posts. The same article states the rule for counting inclusive ranges: for items from m to n inclusive, the correct count is n − m + 1.
Days work the same way. The 1st to the 10th is a range of 10 days inclusive (10 − 1 + 1), while the gap between the two dates is 9 (10 − 1). Decide which one you need before you count.
Some worked examples
- 1 January to 10 January 2026: 9 days between, or 10 days counting the end date.
- 1 January to 31 December 2026: 364 days between, or 365 days counting both ends, which is every day of the year.
- 28 February to 1 March 2024: 2 days, because 2024 is a leap year with a 29 February.
- 28 February to 1 March 2023: 1 day, because 2023 has no 29 February.
- 31 October 2026 to 26 January 2027: 87 days, which is 12 weeks and 3 days, or 2 months and 26 days.
Weeks, months and days
A number of days is often easier to read as weeks. 87 days is 12 weeks and 3 days. Years, months and days are harder because months differ in length, so the calculator takes the most whole months that fit and then counts the days left over, moving a month-end date to the last day of a shorter month. The result is 2 months and 26 days for the last example above.
Leap years
A day count across a leap day includes the extra day. Between 31 December 2023 and 1 March 2024 there are 61 days, because February 2024 has 29 days. A leap year is one divisible by four, except century years that are not divisible by 400, so 2000 and 2024 are leap years and 1900 and 2100 are not.
No time zones, no clocks
The calculator works on calendar dates only, with no time of day. The Python documentation describes the date type as naive, meaning it carries no time zone, and says that subtracting two dates gives an exact result. Because the calculation never uses clock times, a daylight saving change cannot add or remove an hour and shift the answer by a day.
Common mistakes
- Forgetting whether the end date should count, and being off by one.
- Counting 30 days in every month, which is wrong for 28, 29 and 31 day months.
- Using a rough 365 or 30 shortcut for long periods. Use the dates themselves.
- Putting the dates in the wrong order. The calculator works either way and tells you which date it counted from.
How to use the calculator
Pick the start and end dates. By default it shows the days between them. Tick the end date option to count both. The result also shows weeks and days, and years, months and days, which is handy for a project length, a notice period, a warranty or a trip.
Sources
Share
Keep reading
Related articles
How to Calculate Age in Years, Months and Days
How age is counted in years, months and days, how 29 February birthdays and month ends are handled, and how to find the next birthday.
How to Convert Units: Length, Weight, Temperature
How unit conversion works, the exact values worth knowing, why temperature needs an offset, and the common traps with gallons, area and local land units.
How to Create a Strong, Random Password
How long a password should be, why random beats clever, what bits of strength mean, how a fair generator works and why a password manager is the practical answer.