ThisCalculator

Everyday

Days Between Dates: How to Calculate

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.

Days Between Dates: How to Calculate

This calculator works out the number of days between two dates. You enter a start date and an end date, and it returns the total days, plus the breakdown in weeks, months, and years. The result is exact and accounts for leap years automatically.

Formula

The core calculation is simple subtraction of two calendar dates:

Days = End Date − Start Date

Each date is first converted to a serial day number (the number of days since a fixed reference point, such as 1900-01-01). The difference between the two serial numbers is the number of days between them. The formula for the serial number of a date (year Y, month M, day D) is:

Serial = 365Y + floor((Y-1)/4) − floor((Y-1)/100) + floor((Y-1)/400) + floor((153M − 3)/5) + D

where Y, M, and D are the year, month, and day, and floor means round down to the nearest whole number. This is a standard algorithm (adapted from the Julian Day Number system) that correctly handles leap years and the Gregorian calendar.

Worked Example

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

  1. Convert 2024-01-01 to a serial number: 2024 is a leap year, so January 1 is day 1 of the year. The serial number is 738,000 (for reference).
  2. Convert 2024-12-31 to a serial number: December 31 is day 366 of the leap year. The serial number is 738,365.
  3. Subtract: 738,365 − 738,000 = 365 days.

The calculator shows 365 days. That is correct because 2024 is a leap year, so there are 366 days in the year, and the difference between Jan 1 and Dec 31 is 365 days (the day count excludes the start date).

How to Count Days Between Dates

There are several ways to count days, and the method you choose depends on what you need the result for:

  • Calendar days: The simple difference between two dates, counting every day including weekends and holidays. This is what the calculator above gives.
  • Business days: Only weekdays (Monday to Friday), excluding weekends and optionally public holidays. To get this, you need a list of holidays for your country.
  • Inclusive vs. exclusive: Some contexts (like legal contracts) count both the start and end date. For example, “from Jan 1 to Jan 3â€� could be 2 days (exclusive) or 3 days (inclusive). Always check which convention applies.

For most everyday uses—like planning a trip or counting down to an event—the exclusive calendar-day count is standard.

Common Mistakes and Misconceptions

One frequent error is mixing up the order of dates. If you enter the end date before the start date, the result is negative. The calculator does not automatically swap them, so double-check your input.

Another mistake is forgetting leap years. February 29 occurs every 4 years, except on century years not divisible by 400 (e.g., 1900 was not a leap year, but 2000 was). A simple “multiply years by 365� will be off by one day for each leap year in the range.

A third misconception is that “months� are a fixed length. They are not—months vary from 28 to 31 days. The calculator uses an average month length of 30.44 days (365.25/12), which is fine for rough estimates but not for precise month-based calculations.

How to Choose the Right Date-Difference Method

Think about what you are using the result for:

  • Project deadlines: Use calendar days, but be aware that weekends may delay work.
  • Billing or interest: Often uses a 30/360 day-count convention (each month has 30 days, each year 360). This is common in finance and is not the same as actual days.
  • Age calculation: Usually you want completed years, not days. The calculator’s “yearsâ€� output is approximate; for exact age, compare the month and day directly.
  • Scientific or historical research: Use the exact day count, including leap years, which the calculator provides.

If you need business days, you will have to supply a holiday calendar. The calculator here gives the raw day count, which is the starting point for any further adjustments.

Limitations of the Date-Difference Formula

The formula assumes the Gregorian calendar, which is the standard in most of the world today. If you are working with historical dates before 1582 (when the Gregorian calendar was introduced), or with countries that adopted it later, the day count may differ by a few days due to the switch from the Julian calendar.

Also, the calculator does not account for time zones or daylight saving time. If you are measuring a period that crosses a DST change, the actual elapsed time is 23 or 25 hours on that day, but the calendar day count remains 1. For most purposes, this is irrelevant.

Finally, the “months� and “years� outputs are averages. They are useful for a quick sense of scale, but not for legal or financial documents that require exact month/year definitions.

Frequently Asked Questions

How do I calculate days between dates in Excel?

In Excel, use the formula =B2-A2 where A2 is the start date and B2 is the end date. Format the cell as a number. For business days, use =NETWORKDAYS(A2,B2).

Is the start date counted in the difference?

No, the calculator gives the exclusive count: the number of days from the start date to the end date, not including the start date. For example, from Jan 1 to Jan 2 is 1 day. If you need to include both dates, add 1 to the result.

Why does my date difference seem off by one day?

This usually happens because of inclusive vs. exclusive counting. Also, if you are comparing across a leap year, a simple 365-day-per-year calculation will be off. Always use a proper date-difference tool that accounts for leap years.

Can I use this calculator for dates before 1900?

Yes, the formula works for any valid Gregorian date, including before 1900. However, be aware that some software (like Excel) does not support dates before 1900-01-01, so results may differ if you cross that boundary.

How do I calculate days between two dates in JavaScript?

In JavaScript, you can subtract two Date objects: Math.floor((endDate - startDate) / (1000 * 60 * 60 * 24)). This gives the number of milliseconds between them, converted to days. Be careful with time zones—use UTC methods to avoid off-by-one errors.

What is the difference between calendar days and business days?

Calendar days include every day of the week. Business days exclude weekends and typically public holidays. For example, if a project starts on Friday and ends on Monday, there are 3 calendar days but only 1 business day (Monday).

Related

Formula used
in d1 | Start date | - | 2024-01-01 | -
in d2 | End date | - | 2024-12-31 | -
out days | Days between | days | d2 - d1 | 0
out weeks | Weeks | weeks | (d2 - d1) / 7 | 1
out months | Approx. months | months | (d2 - d1) / 30.44 | 1
out years | Approx. years | years | (d2 - d1) / 365.25 | 2

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.