Days Between Dates: How to Calculate the Difference
- Days counting both dates
- days
- Result
- Start date day number
- 1 days
- You entered
- End date day number
- 31 days
- You entered
A days-between-dates calculator finds the number of calendar days separating a start date and an end date: enter both dates, and it returns the elapsed-day count. The calculation normally excludes the start date and includes the end date; if you want to count both dates, add one day.
Formula
For dates represented as consecutive calendar-day numbers, subtract one from the other and take the absolute value:
Elapsed days = |end day number − start day number|
- Start day number is the position of the start date on a continuous calendar-day count, in days.
- End day number is the position of the end date on the same count, in days.
- Absolute value makes the result nonnegative, whichever date comes first.
- Inclusive count adds one when both the first and last calendar dates are to be counted.
The calculator’s inputs are day numbers rather than typed calendar dates. To use it for real dates, convert each date to its position on the same continuous day count, or use a date calculator that accepts month, day, and year directly. Day numbers must use the same calendar and numbering convention.
Worked Example
Using the defaults in the calculator block, the start day number is 1 and the end day number is 31.
- Subtract: 31 − 1 = 30.
- Take the absolute value: |30| = 30 elapsed days.
- For a count that includes both numbered dates: 30 + 1 = 31 days.
These example inputs stand for day numbers, not the dates January 1 and January 31 in any particular year. For actual calendar dates, the conversion to consecutive day numbers must account for month lengths and leap years.
What “Days Between” Usually Means
In ordinary date arithmetic, the difference between two dates is the number of midnight-to-midnight boundaries crossed. For example, from April 10 to April 11 is one elapsed calendar day, even though someone counting the dates inclusively sees April 10 and April 11 and gets two dates.
This distinction explains many apparent disagreements:
- Elapsed-day difference: subtract the start date from the end date. The start is not counted as a completed day.
- Inclusive date count: count every calendar date touched, including both endpoints. For dates in forward order, this is the elapsed difference plus one.
- Same date: elapsed difference is zero; an inclusive count of that one date is one.
If the dates are entered in reverse order, the absolute-difference output still gives a nonnegative interval. An inclusive count is most straightforward when the range is written from the earlier date to the later date.
How Calendar Dates Become a Day Difference
Calendar months do not all have the same length, so subtracting day-of-month numbers alone is not enough. A reliable method maps each full date to a continuous count of days, then subtracts the counts. A calendar or date library performs this conversion while applying the relevant calendar rules.
In the widely used Gregorian calendar, February has 29 days in a leap year and 28 otherwise; the other months have 30 or 31 days. The familiar leap-year rule is that a year divisible by four is a leap year, except a century year must also be divisible by 400. Thus 2000 was a leap year, while 1900 was not. A leap day affects date differences when the interval crosses February 29.
For example, the elapsed difference from February 28 to March 1 is two days in a leap year and one day in a common year. Counting both endpoint dates gives one more than each elapsed difference.
Choosing a Counting Method
Choose the convention that matches the question or the system receiving the result. For “How many days have passed?” use elapsed days. For “How many dates are included in this event?” use an inclusive count if both the first and last dates are part of the event. If instructions specify a convention, follow it rather than assuming that “between” always has one meaning.
For a hand calculation, move forward through the calendar: count the days remaining after the start date in its month, add the full months between, and add the end date’s day number. For dates in the same month, the elapsed difference is simply the difference between their day numbers. This approach is easy to check over short ranges, but converting both dates to a day number or using a date-aware tool is less error-prone over long ranges.
Common Mistakes and Limits
- Counting both endpoints by accident: decide whether you want elapsed days or the number of dates included. Do not add one unless an inclusive count is intended.
- Ignoring the year: the same month and day in different years can be separated by hundreds of days. Always use the full date.
- Forgetting leap day: check whether February 29 falls inside the interval when calculating manually.
- Mixing calendars: a day number is meaningful only when both dates use the same calendar and numbering system. Dates in historical records may require attention to calendar changes and local conventions.
- Confusing dates with exact durations: calendar-day difference is not necessarily the same as elapsed hours divided by 24. A local day can be shorter or longer than 24 hours where clocks change for daylight saving time.
This simple calculator accepts numeric day numbers, so it does not validate a month/day/year combination or identify a calendar. It also measures whole calendar-day steps, not business days, holidays, working hours, or the exact number of seconds between timestamps. A calculation involving times should specify the time zone and daylight-saving rules as well as the dates.
Frequently Asked Questions
Do you count the start date when calculating days between dates?
Usually not. The standard elapsed difference excludes the start date and counts the day boundaries up to the end date. Add one only for an inclusive count that includes both dates.
How many days are there between two dates in the same month?
Subtract the earlier day number from the later one. For example, the elapsed difference from the 5th to the 12th is 7 days; counting both dates gives 8.
Does a leap year change the number of days between dates?
It does if the interval crosses February 29. That extra calendar day increases the elapsed difference by one compared with the corresponding interval in a common year.
Are days between dates the same as nights?
No. A date difference measures calendar-day steps. A trip from one date to the next may involve one night, but nights depend on the actual arrival and departure dates and times.
Can I use this calculation for business days?
Not by itself. Business-day counts exclude selected weekdays and may also exclude public holidays. Those calculations need a weekday rule and, where relevant, a holiday calendar.
Related
Formula used
in start | Start date day number | days | 1 | 0 in finish | End date day number | days | 31 | 0 out days | Days between dates | days | abs(finish - start) | 0 out inclusive | Days counting both dates | days | abs(finish - start) + 1 | 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.