ThisCalculator

Date and time

Calculate Total Days Between Two Dates

Updated · Standard formula, shown below

Total days 1 days
Start date (YYYYMMDD)
20260101
You entered
End date (YYYYMMDD)
20260102
You entered

Calculate Total Days Between Two Dates

To calculate total days between two dates, enter a start date and an end date; the calculator returns the elapsed number of calendar days. For example, the dates January 1 and January 2 are one day apart; whether you count both dates as included days is a separate choice.

Formula

For dates in the same month, subtract the start day from the end day. For dates in different months or years, the correct general calculation is the ordinal-day difference: convert each valid calendar date to its position in the calendar and subtract the start position from the end position. In symbols, elapsed days = ordinal(end date) − ordinal(start date). The ordinal counts days on a continuous calendar, accounting for month lengths and leap years.

The calculator specification above represents dates as YYYYMMDD numbers, but its compact expression is only an approximation and does not correctly account for variable month lengths or leap years. A reliable date calculator must parse the year, month, and day, validate the date, and use a calendar-aware date calculation. The calculation shown in the worked example happens to be exact because the dates are consecutive days in January. Do not rely on that expression for arbitrary dates; use a date-aware implementation or calendar when dates cross month or year boundaries.

  • Start date: the earlier date, entered as year, month, and day.
  • End date: the later date, entered in the same format.
  • Elapsed days: the number of midnight-to-midnight calendar boundaries between the two dates; it is a count, so it has no fractional part.

For example, if a date library assigns January 1 an ordinal value of A and January 2 a value of A + 1, the difference is one day. A proper calculation follows this method for every date rather than assuming months have the same length.

Worked Example

Using the block’s default values, the start date is 2026-01-01 and the end date is 2026-01-02. Both dates fall in January 2026, so the day numbers can be subtracted directly:

  1. End day number: 2.
  2. Start day number: 1.
  3. Elapsed days: 2 − 1 = 1 day.

This is the result for the default dates. It does not mean there is only one calendar date involved: January 1 and January 2 are two dates, but one day elapses from the start of January 1 to the start of January 2.

Elapsed Days Versus Inclusive Counting

The phrase “total days between two dates” can describe two different counts. The standard date-subtraction result is elapsed days: subtract the earlier date from the later date, without counting the starting date as a complete day. Inclusive counting instead counts every calendar date touched, including both endpoints.

  • January 1 through January 2: 1 elapsed day, or 2 dates counted inclusively.
  • January 1 through January 1: 0 elapsed days, or 1 date counted inclusively.
  • January 1 through January 10: 9 elapsed days, or 10 dates counted inclusively.

For a simple inclusive count where both dates are included, add one to the elapsed-day result. This assumes the start date is not after the end date and that the question is about dates, not the exact number of hours between two timestamps. For a period described as “from Monday to Friday,” confirm which convention is intended before using the number.

Why Month Lengths and Leap Years Matter

Calendar dates cannot be reliably subtracted as if every month had 30 days or every year had 365 days. Months have different lengths, and leap years add an extra day to February. In the Gregorian calendar, used by most modern civil date systems, a year is a leap year when it is divisible by 4, except that century years must also be divisible by 400. Thus 2000 was a leap year, while 1900 was not.

For example, February 28 to March 1 is two elapsed days in a common year and three elapsed days in a leap year. The dates look similarly placed on the calendar, but the interval changes because February has 29 days in a leap year. A date-aware calculator accounts for this automatically. If doing the calculation by hand, use a calendar or a trusted date conversion rather than a fixed “days per month” shortcut.

How to Calculate the Difference Reliably

A manual method is to count the days remaining after the start date in its month, add the complete days in any intervening months, then add the days up to the end date. This can work for a short interval, but it is easy to make an off-by-one error or miss February 29. For longer spans, convert both dates to ordinal day numbers using a calendar-aware method and subtract.

In software, a robust approach is to parse each input as a date-only value, validate it, and subtract the two date values using the same calendar and time-zone rules. Avoid converting a date-only question into local midnight timestamps unless necessary: daylight-saving clock changes can make a local day 23 or 25 hours long even though it remains one calendar day. If the question is about exact elapsed hours, use timestamps with a clearly specified time zone instead.

Common Mistakes and Limits

  • Counting both endpoints unintentionally: Decide whether you want elapsed days or inclusive calendar dates. They differ by one when both endpoints are included.
  • Using a fixed month length: Months do not all have 30 days. Account for the actual calendar.
  • Ignoring leap years: A span that includes February may gain an extra day.
  • Reversing the dates: If the end date comes first, subtraction produces a negative interval. Swap the inputs if you want a positive duration.
  • Mixing date systems: The Gregorian calendar is not the only calendar. For historical dates, the calendar in use at the place and time may matter, and adoption of the Gregorian calendar occurred at different times in different regions.
  • Confusing days with 24-hour periods: A date difference counts calendar days, not necessarily exact 24-hour blocks between local clock times.

A calculator also needs valid dates. For instance, February 30 is not a valid Gregorian date. Check that the entered year, month, and day form a real date, and use the same calendar system for both endpoints.

Frequently Asked Questions

Do you count the start date when calculating days between dates?
Usually not. Standard date subtraction counts elapsed days, so the start date is day zero. If you need to count both the start and end dates, use inclusive counting and add one.

How many days are between January 1 and January 10?
There are 9 elapsed days between those dates. If you count every date from January 1 through January 10 inclusively, there are 10 calendar dates.

Does a leap year change the number of days between dates?
Yes, when the interval crosses February 29. For example, February 28 to March 1 is two days in a common year and three in a leap year.

Can I calculate days between dates in Excel or a spreadsheet?
Many spreadsheet programs can subtract one valid date cell from another to return elapsed days. Confirm that both entries are recognized as dates, not plain text, and add one only if you want an inclusive count.

Are calendar days the same as 24-hour periods?
No. A calendar-day difference compares dates. Exact elapsed time compares timestamps, and local clock changes can make the time between two matching local times differ from 24 hours per calendar day.

Related

Formula used
in start | Start date (YYYYMMDD) | - | 20260101 | 0
in finish | End date (YYYYMMDD) | - | 20260102 | 0
out days | Total days | days | (floor(finish/10000)-floor(start/10000))*365.2425+(floor(finish/100)%100-floor(start/100)%100)*30.436875+(finish%100-start%100) | 0

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.