Days Between Dates Calculator: How It Works
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.
The Days Between Dates Calculator works out the exact number of days from one calendar date to another. You enter a start date and an end date, and you get back the total days, plus the difference broken into years, months, and weeks. The calculator below uses the standard Gregorian calendar and counts each day from the start date up to (but not including) the end date, so a difference of one day means the dates are consecutive.
Formula
The calculator converts both dates to their internal timestamp (milliseconds since January 1, 1970, UTC), subtracts the start from the end, and divides by the number of milliseconds in a day.
Days = (Timestampend – Timestampstart) ÷ 86,400,000
- Timestampstart – the internal millisecond value of the start date (ms)
- Timestampend – the internal millisecond value of the end date (ms)
- 86,400,000 – milliseconds in one day (24 hours × 60 minutes × 60 seconds × 1000 ms)
The result is a whole number of days. For weeks and months, the calculator divides the day count by 7 (for weeks) or by 30.4375 (the average month length in the Gregorian calendar, 365.25 ÷ 12).
Worked Example
Using the defaults from the calculator: start date January 1, 2024, end date December 31, 2024.
- Convert both dates to timestamps. January 1, 2024, UTC is 1,704,067,200,000 ms; December 31, 2024, UTC is 1,735,593,600,000 ms.
- Subtract: 1,735,593,600,000 – 1,704,067,200,000 = 31,536,000,000 ms.
- Divide by 86,400,000: 31,536,000,000 ÷ 86,400,000 = 365 days.
- Weeks: 365 ÷ 7 = 52.1 weeks.
- Months: 365 ÷ 30.4375 = 11.99 months.
The calculator shows 365 days, 52.1 weeks, and 12.0 months (rounded to one decimal).
Why the Day Count Can Vary
Different contexts count days differently. The most common convention, used by this calculator, is the exclusive count: the start day is not counted, the end day is not counted, and you get the number of full 24-hour periods between them. For example, from Monday to Tuesday is 1 day. Some applications (like rental agreements or billing cycles) use an inclusive count, where both the start and end days are counted, making Monday to Tuesday 2 days. Always check which convention your situation requires.
Another variation is whether to count only business days (weekdays) or calendar days. This calculator gives calendar days; if you need business days, you must subtract weekends and holidays manually or use a dedicated business-day tool.
How to Use the Calculator Correctly
- Enter the start date in the first field and the end date in the second. The order matters – if you swap them, you’ll get a negative number of days.
- Use the same date format throughout (e.g., YYYY-MM-DD). The calculator accepts most common formats, but consistency avoids errors.
- If you want to count “days from today,� set the start date to today’s date and the end date to your target date.
- For a project deadline, enter the start date as the day work begins and the end date as the day before the deadline to get the number of working days (if weekends are excluded).
Common Mistakes and Misconceptions
One frequent error is assuming that a month is always 30 days. In reality, months range from 28 to 31 days, so a “month� in date arithmetic is an average. The calculator uses 30.4375 days per month, which is accurate over a full year but can be off by a day or two for specific month ranges.
Another mistake is forgetting that the Gregorian calendar has leap years. 2024 is a leap year, so the year has 366 days. If you calculate days from January 1, 2024, to January 1, 2025, you get 366 days, not 365. The calculator handles leap years automatically because it uses actual timestamps.
Time zone differences can also cause off-by-one errors. The calculator works in UTC, so if you enter dates without times, it assumes midnight UTC. If you are in a time zone far from UTC, the “day� boundary might differ from your local midnight. For most date-only calculations, this is negligible, but for precise hour-level work, you need time zone awareness.
What the Result Tells You
The primary result is the total number of days between the two dates. This is useful for:
- Calculating the length of a project or event in days.
- Determining how many days are left until a deadline or birthday.
- Comparing historical dates or ages in days.
- Estimating interest or accrual periods (though financial calculations often use specific day-count conventions like 30/360 or actual/365).
The weeks and months figures are approximations to help you visualize the span. For example, 365 days is about 52 weeks and 1 day, or 12 months. These are not exact calendar months; they are based on averages.
Limitations of the Formula
The formula assumes the Gregorian calendar, which is the standard in most of the world today. It does not account for historical calendar reforms (like the switch from the Julian calendar) or local variations. If you are working with dates before 1582, you may need a specialized historical calendar tool.
The calculator also ignores time-of-day. If you enter dates with times, the result is truncated to whole days. For example, from Jan 1 12:00 to Jan 2 12:00 is exactly 24 hours, which the calculator shows as 1 day. But from Jan 1 23:00 to Jan 2 01:00 is only 2 hours, yet the calculator would show 1 day because it compares the date parts only. For sub-day precision, use a different tool.
Frequently Asked Questions
Does the calculator count the start day?
No. The calculator counts full days between the dates, so the start day is not included. If you enter Jan 1 and Jan 2, the result is 1 day. If you need to include both days, add 1 to the result.
What if I enter the dates in the wrong order?
You will get a negative number of days. The calculator does not automatically swap them. If you see a negative result, simply re-enter the dates in the correct order (earlier date first).
How does the calculator handle leap years?
It handles them automatically because it uses the actual calendar. For example, from Feb 28, 2024, to Mar 1, 2024, is 2 days (Feb 29 is a leap day). The calculator will show 2 days correctly.
Can I use this for business days?
No, this calculator gives calendar days. To get business days, you need to subtract weekends and holidays. Some online business-day calculators allow you to exclude specific holidays.
Why does the months figure sometimes look wrong?
Because it uses an average month length (30.4375 days). For example, from Jan 31 to Mar 1 is 29 days in a non-leap year, which is about 0.95 months. The calculator shows 1.0 months (rounded), which can seem off. For exact month counts, you need to count calendar months manually.
Does the calculator work with dates before 1970?
Yes, it works with a wide range of dates, but the internal timestamp system may have limitations for very old dates (before 100 AD) depending on the browser. For most practical purposes, dates from 1900 onward work reliably.
Related
Formula used
in d1 | Start date | - | 2024-01-01 | 0 in d2 | End date | - | 2024-12-31 | 0 out days | Days between | days | (d2 - d1) / 86400000 | 0 out weeks | Weeks | weeks | ((d2 - d1) / 86400000) / 7 | 1 out months | Approx. months | months | ((d2 - d1) / 86400000) / 30.4375 | 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.