GameParticles
Date & time

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:

SituationCount10 June to 15 June
Days until an eventExclusive5
Nights in a hotelExclusive5
Age of an invoiceExclusive5
Days of leave takenInclusive6
Length of a conference or festivalInclusive6
Rental charged per calendar dayInclusive6

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.

MonthDays before it (common year)Days in month
January031
February3128 (29 in a leap year)
March5931
April9030
May12031
June15130
July18131
August21231
September24330
October27331
November30430
December33431

In a leap year, add 1 to the "days before" figure for March onward.

Worked example: 5 March 2026 to 20 September 2026.

  1. 5 March is day 59 + 5 = 64.
  2. 20 September is day 243 + 20 = 263.
  3. 263 - 64 = 199 days (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.

  1. 17 November is day 304 + 17 = 321. Days left in 2026: 365 - 321 = 44.
  2. No full years in between.
  3. 10 March 2027 is day 59 + 10 = 69.
  4. 44 + 69 = 113 days.

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: 13 days left in November plus 25 = 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)).days returns 113.
  • 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, or end_date - start_date in 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 NETWORKDAYS in 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.

Tools in this guide

Frequently asked questions

How many days until a date?

Subtract today's date from the target date. From 17 November 2026 it is 38 days until 25 December 2026 and 45 days until 1 January 2027. Today is not counted, the target day is.

Do you count the first day when counting days between dates?

By default no. Subtracting dates gives the exclusive count, the number of midnights crossed. Add 1 when both the first and last day count, such as days of leave taken or the days of an event.

How do leap years affect the number of days between dates?

Any span that includes a 29 February is one day longer. Leap years are divisible by 4, except century years that are not divisible by 400. So 2024 and 2028 have 366 days, and 2100 will have 365.

How do I calculate days between two dates in Excel?

Put the dates in two cells and subtract: =B1-A1, with the result cell formatted as a number. =DAYS(B1,A1) does the same. Use =NETWORKDAYS(A1,B1) for working days, which counts both end dates and skips weekends.

More date & time guides

JSON Formatter
Developer · Format, validate and minify JSON with syntax highlighting.
↵
Base64 Encode / Decode
Developer · Encode text to Base64 or decode Base64 back to plain text.
↵
URL Encoder / Decoder
Developer · Encode or decode URL components and query strings.
↵
Hash Generator
Developer · Generate MD5, SHA-1, SHA-256 and SHA-512 hashes.
↵
UUID Generator
Developer · Generate UUIDs v4 (random) in bulk with one click.
↵
Regex Tester
Developer · Test regular expressions against text with live match highlighting.
↵
Word Counter
Text · Count words, characters, sentences, paragraphs and reading time.
↵
Case Converter
Text · Convert text between UPPER, lower, Title, camelCase, snake_case and more.
↵
List Sorter
Text · Sort, reverse, deduplicate and shuffle lists of text.
↵
Markdown Preview
Text · Write Markdown and see a live rendered preview side by side.
↵
Percentage Calculator
Numbers · Calculate percentages, increases, decreases and what % one number is of another.
↵
Color Converter
Colors · Convert colors between HEX, RGB, HSL and HSV instantly.
↵
Snake
Arcade · Eat food, grow longer, don't hit the walls. A timeless classic.
↵
2048
Puzzle · Slide tiles and combine them to reach the legendary 2048 tile.
↵
Word Grid
Puzzle · Guess the hidden five letter word in six tries using color clues.
↵
Sudoku
Puzzle · Fill the 9x9 grid with logic. Four difficulties from easy to expert.
↵
Minesweeper
Strategy · Use number clues to clear the minefield. Classic logic, three levels.
↵
Breakout
Arcade · Smash every brick with paddle and ball. Power-ups, combos, endless levels.
↵
Typing Practice
Casual · Build your WPM and accuracy with timed drills from 30 seconds to 5 minutes. Find your weak keys.
↵
TypeRunner
Arcade · Multiplayer typing race. Race friends by link, beat computer runners, or chase your own ghost.
↵
Typing Blocks
Arcade · Type each word before its wooden block lands. Miss, and the pile climbs toward the line.
↵
Bubble Shooter
Arcade · Aim, bank shots off the walls, and pop groups of three or more bubbles.
↵
Road Rush
Arcade · Race seven rivals through traffic and punch your way to the front.
↵