ThisCalculator

Everyday

Interval Day Calculator: How to Count Days Between Dates

Updated · Standard formula, shown below

The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.

Interval Day Calculator: How to Count Days Between Dates

An interval day calculator works out the exact number of days between two dates, and you can use it to find the gap from a start date to an end date, or to add or subtract a set number of days from a given date. You enter the two dates (or a date and a number of days) and the calculator returns the difference in days, often also showing weeks and months for context. This page explains how the calculation works, how to use it correctly, and the common pitfalls that lead to wrong results.

Formula

The core formula is simple: Days = (End Date – Start Date) ÷ 86,400,000. Here, the subtraction of two date objects yields the difference in milliseconds (since each date is stored as the number of milliseconds since January 1, 1970, UTC). Dividing by 86,400,000 (the number of milliseconds in one day: 24 × 60 × 60 × 1000) converts that to whole days.

For adding or subtracting days, the formula is: Result Date = Start Date + (Number of Days × 86,400,000). The calculator then formats that millisecond value back into a calendar date.

Variables:

  • Start Date – the earlier date, in YYYY-MM-DD format (e.g., 2024-01-01).
  • End Date – the later date, in YYYY-MM-DD format (e.g., 2024-12-31).
  • Days – the integer number of days between the two dates, excluding the start date but including the end date (i.e., the difference in calendar days).
  • Weeks – days divided by 7, shown as a decimal (e.g., 365/7 = 52.1).
  • Months – days divided by the average month length (30.44 days), giving an approximate value, not a calendar-month count.

Worked Example

Using the default values from the calculator: start date = 2024-01-01, end date = 2024-12-31.

  1. Convert both dates to milliseconds since the epoch (Jan 1, 1970). For 2024-01-01, that is 1704067200000 ms; for 2024-12-31, it is 1735689600000 ms.
  2. Subtract: 1735689600000 – 1704067200000 = 31622400000 ms.
  3. Divide by 86,400,000: 31622400000 / 86400000 = 366 days.
  4. The calculator rounds to 0 decimals, so it shows 366 days.
  5. Weeks: 366 / 7 = 52.3 weeks (rounded to 1 decimal).
  6. Months: 366 / 30.44 = 12.0 months (rounded to 1 decimal).

Note: 2024 is a leap year, so there are 366 days between Jan 1 and Dec 31, not 365. This example highlights why you should not assume a year is always 365 days.

How the Calculator Works Internally

Most date calculations rely on the internal representation of dates as a single number—the count of milliseconds since a fixed point (the Unix epoch). This approach avoids the complexity of manually counting days in months and leap years. The calculator performs these steps:

  • Parses the input strings (e.g., “2024-01-01â€�) into date objects. The YYYY-MM-DD format is universally recognized and avoids ambiguity (unlike MM/DD/YYYY vs DD/MM/YYYY).
  • Converts both dates to their millisecond timestamps.
  • Subtracts the start timestamp from the end timestamp to get the difference in milliseconds.
  • Divides by the fixed number of milliseconds per day (86,400,000).
  • Rounds to the nearest integer for the day count, since the division should yield a whole number if both dates are valid and the time-of-day component is zero.

For adding days, the calculator adds the product of days and 86,400,000 to the start timestamp, then converts back to a date string. This method automatically handles leap years and month lengths because the date arithmetic is done at the millisecond level.

When to Use an Interval Day Calculator

You might need to know the exact number of days between dates for many practical reasons:

  • Project planning: Determining how many days a task spans from kickoff to deadline.
  • Billing or subscription periods: Calculating the number of days in a service period (e.g., a 30-day trial that started on a specific date).
  • Age calculation: Finding the exact number of days since a birthdate, which is more precise than just years.
  • Event countdowns: Knowing how many days until a holiday, wedding, or travel date.
  • Historical research: Counting days between historical events, especially when weeks or months are not consistent.
  • Legal or contractual deadlines: Many contracts specify “within 30 daysâ€� or “after 90 days,â€� and you need to compute the exact calendar date.

The calculator is also useful for adding or subtracting days: for example, “What date is 45 days from today?� or “What was the date 90 days ago?�

How to Choose the Right Date Format and Input

To get accurate results, follow these guidelines:

  • Use the YYYY-MM-DD format (e.g., 2024-03-15). This is the ISO 8601 standard and avoids confusion between month and day order.
  • Always include the year with four digits (e.g., 2024, not 24). Two-digit years can be misinterpreted.
  • Be consistent with the start and end dates. The calculator subtracts start from end; if you enter them in reverse, you’ll get a negative number.
  • Decide whether to include the end date. The calculator returns the number of days between the dates, meaning the start date is not counted, but the end date is. For example, from Jan 1 to Jan 2 is 1 day. If you need to count both endpoints (e.g., “how many days are in a rental periodâ€�), you may need to add 1.

If you are adding days to a date, ensure you enter a positive number for future dates and a negative number for past dates (e.g., -30 for 30 days ago).

Common Mistakes and How to Avoid Them

Even with a calculator, errors can creep in. Here are the most frequent pitfalls:

  • Mixing up date formats: Entering 03/04/2024 could mean March 4 or April 3, depending on your locale. Always use the YYYY-MM-DD format.
  • Assuming 30 days in every month: For month-based calculations, using an average of 30.44 days is more accurate, but for exact day counts, the calculator’s method is correct.
  • Forgetting leap years: February has 29 days in leap years (like 2024), which adds an extra day to any interval that spans it. The calculator handles this automatically.
  • Rounding too early: If you need the exact number of days, don’t round intermediate results. The calculator rounds only the final output.
  • Including the start date: If you want to count the number of days including both the start and end dates, you must add 1 to the result. For example, a trip from Jan 1 to Jan 3 is 2 days if you exclude the start, but 3 days if you count both.

Also, be aware that the calculator assumes dates are in the same time zone (UTC). If you are in a time zone with daylight saving changes, the difference in days might be off by one if you cross a DST boundary at midnight. In practice, for most date-only calculations, this is negligible, but for precise legal or scientific purposes, specify the time zone.

Limitations of the Calculator

While the interval day calculator is accurate for counting days, it has some limitations:

  • It does not account for time-of-day. If you enter dates with times (e.g., 2024-01-01 12:00), the calculator may return a fractional number of days, which is rounded. For date-only inputs, this is not an issue.
  • It does not handle business days. If you need to count only weekdays (Monday-Friday), you’ll need a separate business day calculator that excludes weekends and holidays.
  • It does not convert to other calendars. The calculator uses the Gregorian calendar, which is the standard today, but not for historical dates before 1582 or in some cultures.
  • It does not give calendar months. The “monthsâ€� output is an average (days / 30.44), not the actual number of calendar months. For example, from Jan 31 to Feb 28 is 28 days, which is less than a month, but the calculator would show 0.9 months.

For most everyday uses, these limitations are irrelevant, but it’s good to know when you need more specialized calculations.

Frequently Asked Questions

How do I calculate the number of days between two dates manually?

To do it manually, count the days in each month from the start date to the end date, being careful to include the end date and exclude the start date. For example, from Jan 15 to Mar 10: Jan has 31 days, so from Jan 15 to Jan 31 is 16 days (excluding Jan 15). February has 28 days (or 29 in a leap year), and March has 10 days. Total = 16 + 28 + 10 = 54 days (or 55 in a leap year). This method is error-prone, which is why a calculator is recommended.

Does the calculator include the start and end dates?

No, it excludes the start date and includes the end date. For example, from Jan 1 to Jan 2 is 1 day. If you need to count both dates (e.g., “how many days is my vacation?�), add 1 to the result. So a trip from Jan 1 to Jan 3 would be 2 days (calculator) but 3 days if you count both.

What is the difference between calendar days and business days?

Calendar days include every day of the week (Monday through Sunday). Business days typically exclude weekends (Saturday and Sunday) and often public holidays. For example, 10 calendar days from a Monday would be the next Thursday (including the weekend), but 10 business days would be two weeks later (excluding weekends). This calculator counts calendar days only.

Why is the number of days different from what I get by counting months?

Months have varying lengths (28, 30, or 31 days), so a month is not a fixed number of days. For instance, from Jan 31 to Feb 28 is 28 days, but from Feb 28 to Mar 28 is 28 days as well (in a non-leap year). The calculator gives the exact number of days, while a month-based estimate (e.g., 1 month = 30 days) is approximate.

Can I calculate the number of days until a future date?

Yes, simply enter today’s date as the start date and the future date as the end date. The calculator will show the number of days between them. For example, if today is March 1, 2025 and the event is May 1, 2025, the result is 61 days (assuming no leap year).

How do I add or subtract days from a date?

Enter the start date and the number of days in the appropriate field. For adding days, use a positive number; for subtracting, use a negative number (e.g., -45). The calculator will output the resulting date. For example, adding 30 days to 2024-01-15 gives 2024-02-14.

Related

Formula used
in start | Start date (YYYY-MM-DD) | - | 2024-01-01 | 0
in end | End date (YYYY-MM-DD) | - | 2024-12-31 | 0
out days | Days between | days | (end - start) / 86400000 | 0
out weeks | Weeks (approx) | weeks | days / 7 | 1
out months | Months (approx) | months | days / 30.44 | 1

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.