OnlineTimeNow

How to Count the Days Between Two Dates

How to Count the Days Between Two Dates

To count the days between two dates, subtract the earlier date from the later one. The result counts every day after the start date up to and including the end date, so from July 14 to December 25, 2026 is 164 days. If you need both the first and the last day included, add 1.

The quick answer

Every date calculator, spreadsheet and programming language does the same thing by default: it treats the dates as points and measures the distance between them. July 14 to July 15 is 1 day. July 14 to July 14 is 0 days. That is the "exclusive" count, and it is right for most questions that start with "how long until" or "how long ago".

The date calculator on this site gives that number, plus the same span in weeks and days, in years, months and days, and in business days. Tick "Include the end date" when you need the inclusive count instead. The only real decision is which of the two you need, and that depends on what you are counting.

Inclusive or exclusive?

This is the fencepost problem. A fence 40 meters long with a post every 10 meters has four gaps but five posts. Dates work the same way: from Monday to Friday there are four steps but five days. Ask yourself whether you are counting the gaps (nights, elapsed time) or the posts (days on which something happens).

Which count to use
What you are countingConventionExample
Hotel nights, rental periods billed by nightExclusive (end minus start)Check in July 10, out July 14: 4 nights
Days of an event, a course or a festivalInclusive (end minus start, plus 1)July 14 to July 18: 5 days
Days until a date ("how many days until")Exclusive, today not countedJuly 14 to December 25: 164 days
US federal court deadlines ("within 30 days after")Skip the trigger day, count the last dayServed July 14: day 30 is August 13
Visa stays, leave entitlements, contractsWhatever the document saysRead the rule; do not assume

The court rule is a good model of careful drafting. Rule 6(a) of the Federal Rules of Civil Procedure says to exclude the day of the triggering event, count every day including weekends and holidays, and include the last day, unless that last day is a Saturday, Sunday or legal holiday, in which case the period runs to the next working day. Many contracts borrow that wording. When a contract is silent, ask, because "30 days from July 14" can honestly mean August 13 or August 12.

For visas, the issuing authority's rules decide. The European Union, for example, publishes an official short-stay calculator for its rule of 90 days in any 180-day period, and it is safer to use that than to count by hand.

Counting by hand

For two dates in the same month, subtract the day numbers: July 3 to July 29 is 26 days. Across months, split the span into three parts: what is left of the first month, the full months in between, and the days used in the last month.

  1. Days left in the start month: the month's length minus the start day.
  2. Add the lengths of every full month in between.
  3. Add the day number of the end date.

Example: March 15 to October 2, 2026. March has 31 days, so 31 minus 15 leaves 16. April to September add 30 + 31 + 30 + 31 + 31 + 30 = 183. October adds 2. The total is 16 + 183 + 2 = 201 days.

You need the month lengths: January 31, February 28 (29 in a leap year), March 31, April 30, May 31, June 30, July 31, August 31, September 30, October 31, November 30 and December 31. The knuckle trick still works: make two fists, and every knuckle is a 31-day month while every dip between them is a shorter one.

Leap years are the other trap. In the Gregorian calendar a year is a leap year if it divides by 4, except century years, which must divide by 400. So 2000 was a leap year and 2100 will not be. From February 28 to March 1 is 2 days in 2028 and 1 day in 2027. Our post on leap year rules has the full story.

Weeks, months and years between dates

Weeks are easy because every week has seven days: divide by 7 and keep the remainder. The 164 days from July 14 to December 25 are 23 weeks and 3 days. If you want calendar weeks rather than blocks of seven days, ISO week numbers are the standard way to label them.

Months are where answers start to disagree, because months are not all the same length. Most tools count a month as complete only when the same day number comes round again. March 15 to October 2 is 6 months and 17 days: March 15 to September 15 makes the 6 months, and September 15 to October 2 adds 17 days.

The awkward case is the end of a month. What is one month after January 31? There is no February 31, so some systems say February 28, others March 3. Google Sheets' DATEDIF counts a month only when the end date reaches the start's day number, so it reports 4 months between September 30, 2015 and February 28, 2016, although February 28 was the last day of its month. When months matter (rent, subscriptions, age), state the rule you used. Our age calculation guide deals with the February 29 birthday version of this problem.

Spreadsheet formulas

Excel and Google Sheets store dates as serial numbers, one per day, so plain subtraction works. With the start date in A1 and the end date in B1:

FormulaResultNotes
=B1-A1Days, start day excludedFormat the cell as Number, or you get a date
=B1-A1+1Days, both ends includedThe inclusive count
=DAYS(B1,A1)Same as B1-A1End date comes first
=DATEDIF(A1,B1,"D")Same as B1-A1Start date first; error if start is after end
=DATEDIF(A1,B1,"M")Whole monthsCounts a month only when the day number is reached
=DATEDIF(A1,B1,"Y")Whole yearsThe usual age formula

Two warnings. Microsoft documents DATEDIF as a function kept for compatibility with old Lotus 1-2-3 workbooks and advises against its "MD" unit because of known limitations. And DAYS takes its arguments in the opposite order from DATEDIF, which is the commonest reason for a negative answer. For working days only, Excel and Sheets have NETWORKDAYS; our post on counting business days covers it, along with holidays.

Edge cases

Daylight saving days

A calendar day is not always 24 hours long. In New York, March 8, 2026 had 23 hours and November 1, 2026 will have 25. Code that subtracts two timestamps and divides by 86,400 seconds can drop a day: from midnight on March 1 to midnight on March 10, 2026 in New York is 9 calendar days but only 215 hours, which is 8.96 "days", and a program that rounds down reports 8. Count dates as dates, not as hours divided by 24. The daylight saving time guide explains which days are short or long where you live.

Time zones and the date line

A date is local. At 11 p.m. on July 14 in Los Angeles, it is already the afternoon of July 15 in Sydney. If a deadline involves people in different places, agree whose calendar counts, and give the time zone with the date. For a deadline that sits at a precise moment, a countdown to that time is clearer than a day count.

Very old dates

Countries switched from the Julian to the Gregorian calendar in different years, from 1582 onward, and dropped 10 or more days when they did. Calculators, including ours, use the Gregorian calendar throughout, so a day count that crosses a historical switch in the country you are studying needs adjusting by hand.

Use the calculator

For one-off questions, the date calculator gives the exclusive count, the inclusive count with one tick, and the weeks, months, years and business days in between. To find a date a fixed number of days away, read what date is 30, 60 or 90 days from today. To watch the days fall away instead, count down to any date or set up a countdown. For calendar weeks, the week number tool shows the ISO week of any date.

Before you trust any day count, decide whether both ends belong in it. Then put the two dates into the date calculator and read off the number you need.

Frequently asked questions

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

Normally no: the standard count, end date minus start date, leaves out the start day and includes the end day. Add 1 if both days should count, as with the days of an event.

How many days are there between two dates in the same month?

Subtract the earlier day number from the later one. From July 3 to July 29 is 26 days, or 27 if you include both days.

What is the Excel formula for days between dates?

Subtract the cells, =B1-A1, and format the result as a number. =DAYS(B1,A1) and =DATEDIF(A1,B1,"D") give the same result.

How many days are in a year?

A common year has 365 days and a leap year has 366, with February 29 as the extra day. Over the 400-year Gregorian cycle the average is 365.2425 days.

Last updated:

Every date, offset and calculation on this page was checked against the sources below.

  1. Microsoft Support: DATEDIF function
  2. Google Docs Editors Help: DATEDIF
  3. US Naval Observatory: Introduction to Calendars
  4. Federal Rules of Civil Procedure, Rule 6 (Cornell LII)