Days Between Two Dates

Measure elapsed calendar days or count both endpoint dates with semantics shown before you calculate.

Explicit endpoint rules
Leap-year aware
DST-independent

How to Count Days Between Dates

Select a start date and an end date on or after it. Then choose whether you need elapsed days, which excludes the end date, or an inclusive date count, which includes both start and end dates.

1

Select the start date.

State the counting rule

A result without endpoint semantics is ambiguous. For the same date, elapsed days is 0 while an inclusive date count is 1.

Elapsed Days Versus Inclusive Days

Elapsed-day mode measures how many midnight boundaries separate the start date from the end date. It treats the interval as [start, end), including the start boundary and excluding the end boundary. Inclusive mode counts the calendar labels in [start, end], so it adds one to the elapsed result. The inputs never become local timestamps, which prevents daylight-saving transitions from turning a two-date interval into a fractional number of days.

Date Difference Examples

Elapsed date difference

Date range

startDate:2024-03-09
endDate:2024-03-11
countingMode:exclusive-end

Day count

2 days

Two calendar-day boundaries are crossed, regardless of a local daylight-saving change.

Inclusive event dates

Date range

startDate:2024-03-09
endDate:2024-03-11
countingMode:inclusive

Day count

3 days

March 9, March 10 and March 11 are each counted.

Intervals and named dates differ

Use elapsed mode for duration-like differences and inclusive mode when counting all calendar dates in a schedule.

Frequently Asked Questions

Elapsed mode excludes it. Inclusive mode includes both the start and end dates.

Still have questions about this calculation?

Try the Calculator

Days-Between Formula

Each valid date is mapped to an integer UTC day index after parsing its Gregorian year, month and day.

Formula

days ​=​ day index​(​end​)​ − day index​(​start​)​

Elapsed days

days ​=​ day index​(​end​)​ − day index​(​start​)​

Inclusive date count

days ​=​ day index​(​end​)​ − day index​(​start​)​ ​+​ 1

Scientific Background

Using a date-only day index avoids local UTC offsets and daylight-saving changes. It should not be used to infer an exact duration in hours between two timestamps.