A two-day gap contains three dates when both endpoints count
The gap from 2024-02-28 to 2024-03-01 is two days. Counting both endpoints gives February 28, February 29 and March 1: three dates. Moyoutil’s Include start date option counts both endpoints. The same date gives zero by default and one when included.
dateDiff("2024-02-28", "2024-03-01", false) // 2
dateDiff("2024-02-28", "2024-03-01", true) // 3
dateDiff("2024-03-01", "2024-03-01", false) // 0
dateDiff("2024-03-01", "2024-03-01", true) // 1A result is negative when the end date precedes the start. Reversing this example gives -2 by default and -3 with inclusion. Inclusion preserves direction. If your schedule needs an unsigned count, check the start and end order first.
Leap years: check the exception for century years
Under ECMAScript’s Gregorian rules, years divisible by 4 are leap years unless divisible by 100; those must also be divisible by 400. Thus 2000 is a leap year and 1900 is not. The actual function gives two days from 2000-02-28 to 2000-03-01, and one for the same month and day in 1900.
dateDiff("2000-02-28", "2000-03-01") // 2
dateDiff("1900-02-28", "1900-03-01") // 1Moyoutil appends T00:00:00Z to each date to calculate at UTC midnight, then divides the millisecond difference by 86400000. A day in this ECMAScript time model is 86400000 milliseconds. This tool does not take local times or daylight-saving changes as inputs to calculate actual elapsed time.
Check the counting basis before using the result
Choose the start and end dates. Check whether the result is the default difference or the endpoint count with Include start date selected, and read the displayed calculation basis. Results update when inputs change. Supported years are 0001–9999; nonexistent dates and empty inputs produce errors.
The tool counts calendar dates without excluding weekends or holidays. It does not apply separate rules for business days, lodging charges, age, contract end dates or legal deadlines, nor reconstruct calendars historically used by a region. Check the service or organization’s inclusion and calendar rules first.
Frequently Asked Questions
Does inclusion always add one to the default result?
No. For a negative difference it subtracts one to preserve the negative direction. Including the same date gives one day.
Does a two-day result mean 48 hours actually elapsed?
The tool compares dates at UTC midnight. Actual local start and end times and time-zone changes are not inputs, so the result alone cannot establish actual elapsed time.