How Many Days Between Dates: Count Them Step by Step
Work out how many days between dates by hand, in a spreadsheet or in code. Covers inclusive vs exclusive counting, leap years and how many days until a date.
Updated
To find how many days are between two dates, subtract the earlier date from the later one. The result counts the days after the start date up to and including the end date, so 1 March to 31 March is 30 days. If both the first and last day should count, add 1.
Exclusive versus inclusive counting
Most wrong answers come from this one choice, not from arithmetic.
- Exclusive (the default): count the midnights you cross. Monday to Friday of the same week is 4 days. This is what subtraction, spreadsheets and programming languages return.
- Inclusive: count every calendar day touched, including both ends. Monday to Friday is 5 days. This is exclusive plus 1.
Which one is right depends on the question:
| Situation | Count | 10 June to 15 June |
|---|---|---|
| Days until an event | Exclusive | 5 |
| Nights in a hotel | Exclusive | 5 |
| Age of an invoice | Exclusive | 5 |
| Days of leave taken | Inclusive | 6 |
| Length of a conference or festival | Inclusive | 6 |
| Rental charged per calendar day | Inclusive | 6 |
Legal and contract deadlines often have their own rule, such as "the day of the event is not counted", so read the wording before relying on either method.
Counting by hand with day-of-year numbers
For two dates in the same year, convert each to its day number within the year and subtract. The table gives the number of days before each month starts.
| Month | Days before it (common year) | Days in month |
|---|---|---|
| January | 0 | 31 |
| February | 31 | 28 (29 in a leap year) |
| March | 59 | 31 |
| April | 90 | 30 |
| May | 120 | 31 |
| June | 151 | 30 |
| July | 181 | 31 |
| August | 212 | 31 |
| September | 243 | 30 |
| October | 273 | 31 |
| November | 304 | 30 |
| December | 334 | 31 |
In a leap year, add 1 to the "days before" figure for March onward.
Worked example: 5 March 2026 to 20 September 2026.
- 5 March is day
59 + 5 = 64. - 20 September is day
243 + 20 = 263. 263 - 64 = 199days (exclusive), or 200 counting both ends.
For dates in different years, split the span into three parts: the days left in the start year, the full years in between (365 or 366 each), and the day number in the end year.
Worked example: 17 November 2026 to 10 March 2027.
- 17 November is day
304 + 17 = 321. Days left in 2026:365 - 321 = 44. - No full years in between.
- 10 March 2027 is day
59 + 10 = 69. 44 + 69 = 113days.
Leap years
The Gregorian leap year rule has three parts:
- A year divisible by 4 is a leap year.
- Except years divisible by 100, which are not.
- Except years divisible by 400, which are.
So 2024, 2028 and 2032 are leap years, 1900 and 2100 are not, and 2000 was. A span only gains the extra day if it actually contains 29 February. 1 February 2024 to 1 March 2024 is 29 days, while the same dates in 2026 give 28.
For long spans, a quick estimate is years x 365.25, but the exact figure depends on how many leap days fall inside the range. Ten years can be 3,652 or 3,653 days.
How many days until a date
"Days until" is the same subtraction with today as the start. Today is not counted and the target day is, which matches how people speak: on 24 December, Christmas is 1 day away.
From 17 November 2026:
- Until 25 December 2026:
13days left in November plus25= 38 days. - Until 1 January 2027:
13 + 31 + 1= 45 days.
For a countdown that includes hours and minutes, the answer changes through the day. 38 days at midnight becomes 37 days and 12 hours at noon. Decide whether you want whole calendar days or elapsed time before quoting a number.
Spreadsheets and code
Every tool stores dates as a count of days or seconds, so the difference is a subtraction:
- Excel and Google Sheets:
=B1-A1, or=DAYS(B1,A1).=DATEDIF(A1,B1,"d")also works, and"m"or"y"return complete months or years. - Working days:
=NETWORKDAYS(A1,B1)counts Monday to Friday inclusive of both ends, with an optional list of holidays as a third argument. - Python:
(date(2027, 3, 10) - date(2026, 11, 17)).daysreturns113. - JavaScript:
Math.round((Date.UTC(2027, 2, 10) - Date.UTC(2026, 10, 17)) / 86400000). Months are zero-based, and building the dates in UTC avoids daylight saving errors. - SQL:
DATEDIFF(end, start)in MySQL, orend_date - start_datein PostgreSQL.
Avoid dividing a difference in local-time milliseconds by 86,400,000 and rounding down. On the day clocks go forward, a local day is only 23 hours long, so a span across it comes out a fraction short of a whole number and floors to one day too few. Use date-only types or UTC.
If you already have Unix timestamps, subtract them and divide by 86400.
Using the Duration Calculator
The Duration Calculator takes a start and an end date with times and shows the gap two ways: a calendar breakdown in years, months, days, hours, minutes and seconds, and totals in days, hours, minutes and seconds. A swap button reverses the two dates, and each figure has a copy button.
Three things to know when using it for day counts:
- Total Days is the exclusive count of complete 24-hour days. Add 1 yourself for an inclusive count.
- It has no working-day mode. For business days, use
NETWORKDAYSin a spreadsheet. - Times are read in your local time zone. If the range crosses a daylight saving change and both times are 00:00, the span can be an hour short of a whole day. Setting the end time to 12:00 keeps Total Days correct.
To turn the result into weeks, divide by 7. There is more on that in how many weeks in a year.
Try it
Open the Duration Calculator, enter 17 November 2026 as the start and 10 March 2027 as the end, and check that it reports 113 days, shown in the breakdown as 3 months and 21 days.