ThisCalculator

Date and time

Calculate Duration Between Two Dates

Updated · Standard formula, shown below

Duration between dates 30 days
Days including both dates
31 days
Result
Start date as days since a fixed reference
0 days
You entered
End date as days since the same reference
30 days
You entered

Calculate Duration Between Two Dates

To calculate the duration between two dates, subtract the earlier date from the later one; the result is the elapsed time, usually expressed as a number of days. Enter a start date and an end date in the calculator to get the calendar-day difference, then decide whether your count should include the start date, the end date, or both.

Formula

Elapsed duration: D = |E − S|. Inclusive date count: I = |E − S| + 1. Here, S is the start date’s day number and E is the end date’s day number, with both dates converted to whole days on the same calendar scale. D is elapsed calendar days; I counts the dates touched, including both endpoints. The calculator’s numeric fields represent day numbers, rather than a conventional year-month-day date entry. In a calendar-based calculator, those day numbers are generated from the dates you enter.

The absolute value makes the elapsed difference nonnegative even if the dates are entered in reverse order. If direction matters—for example, to tell whether a deadline has passed—retain which date is earlier instead of relying only on the absolute result.

Worked Example

Using the calculator’s default values, S = 0 days and E = 30 days:

  1. Elapsed duration: D = |30 − 0| = 30 days.
  2. Inclusive count: I = |30 − 0| + 1 = 31 days.

The headline answer is 30 days. The inclusive count is 31 because it counts day 0 and day 30 as well as the dates between them.

How to Calculate a Date Difference

For ordinary dates, use a calendar or date-difference tool that recognizes the calendar rules, including leap years. To calculate manually, count the complete days from the earlier date up to—but not including—the later date. For example, from March 1 to March 4 is three elapsed days: March 1 to March 2, March 2 to March 3, and March 3 to March 4.

  • Write down both dates and confirm which comes first.
  • Choose whether the question asks for elapsed days or an inclusive count of calendar dates.
  • Use the same calendar and, if times are involved, specify the time zone.
  • Report the result with its unit and counting convention, such as “30 elapsed days” or “31 dates inclusive.”

For dates with times, subtract the actual timestamps to find elapsed hours, minutes, or seconds. A difference between local midnights is not always exactly 24 hours when a time zone changes its clocks for daylight saving time. If precise elapsed time matters, compare timestamps in a consistent time zone, commonly Coordinated Universal Time (UTC).

Elapsed Days Versus Inclusive Counting

These two methods answer different questions. Elapsed duration measures the gap between the dates. Inclusive counting counts every calendar date from the first through the last. If an event runs from Monday through Wednesday, it spans two elapsed days but covers three named dates: Monday, Tuesday, and Wednesday.

This distinction explains many apparent one-day disagreements. A person asking “How many days until Friday?” usually means the elapsed gap and does not count today as a full additional day. A schedule listing the dates on which work occurs may need an inclusive count. State the method whenever the number will be used in a plan, report, or agreement.

Calendar Months, Years, and Leap Years

A month is not a fixed number of days: calendar months contain 28, 29, 30, or 31 days. A year is also not always 365 days. In the Gregorian calendar, a year is a leap year if it is divisible by 4, except century years must also be divisible by 400. Thus 2000 was a leap year, while 1900 was not.

For this reason, a duration in days should not automatically be converted into months by dividing by 30, or into years by dividing by 365, unless an approximate value is acceptable. A date interval such as January 31 to February 28 may be described as 28 elapsed days in a common year, but whether it counts as “one month” depends on the convention or software being used. When a task asks for years, months, and days, use calendar arithmetic and specify how month-end dates are handled.

Common Problems and Limitations

  • Counting both endpoints by accident: Subtracting dates gives elapsed days, not the inclusive number of dates. Add one only when both endpoints should be counted.
  • Ignoring leap day: An interval that crosses February 29 includes that calendar day. A correct date calculator accounts for it automatically.
  • Mixing dates and times: Two dates alone produce a calendar-day difference. Exact elapsed hours require times and a time-zone rule.
  • Rounding too early: For dates this is usually avoidable because whole dates differ by whole days. For timestamps, retain full precision until the final display.
  • Assuming a universal month length: Calendar months vary, so a conversion from days to months is only meaningful under a stated convention.

The calculator specification above uses day numbers so its formula remains simple and transparent; the inputs are not intended as a convenient way to type dates. A practical date-entry calculator must convert each entered calendar date to a consistent day number before applying the subtraction. Date arithmetic also depends on the calendar system. For historical dates, check which calendar is intended, since not every country adopted the Gregorian calendar at the same time.

Frequently Asked Questions

Do I count the start date when calculating days between dates?
For elapsed duration, no: subtract the earlier date from the later date. Count the start date only for an inclusive total of calendar dates, which is one more than the elapsed-day difference when both endpoints are included.

How many days are between two dates?
Convert both dates to the same calendar’s day numbers and subtract the earlier from the later. The result is the elapsed number of days; the precise answer depends on the dates and whether you want inclusive counting.

Does a date calculator include leap years?
A calendar-aware calculator should. Leap years add February 29, so an interval crossing that date has one more elapsed day than it would across the same dates in a non-leap year.

How do I calculate the number of months between two dates?
Use calendar-month arithmetic rather than dividing days by 30. The answer can depend on how partial months and dates at the end of a month are treated, so state the convention.

Can I calculate hours between two dates?
Yes, if you provide a time as well as each date. Compare both date-time values in the same time zone; daylight-saving changes can make the elapsed hours differ from the number of date boundaries multiplied by 24.

Related

Formula used
in start | Start date as days since a fixed reference | days | 0 | 0
in end | End date as days since the same reference | days | 30 | 0
out days | Duration between dates | days | abs(end - start) | 0
out inclusive | Days including both dates | days | abs(end - 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.