ThisCalculator

Date and time

Dates Until Calculator: Count Days Accurately

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.

Dates Until Calculator: Count Days Accurately

This calculator works out the number of days between two dates, showing the total, weekdays, and weekends. You enter a start date and an end date, and it returns the exact day count, along with a breakdown by day type. It uses the standard calendar-day difference, so the result is the number of midnights between the two dates.

Formula

The core formula is simple: Total days = End date − Start date, where each date is converted to a timestamp (milliseconds since January 1, 1970). Dividing the difference in milliseconds by 86,400,000 (the number of milliseconds in a day) gives the number of whole days. The result is an integer because the calculator truncates any fractional part.

For the weekend count, the formula uses the day of the week of the start date (where Monday = 0, Sunday = 6) and the total number of days. The number of full weeks is floor((total + (start_weekday + 1) % 7) / 7), and each full week contains two weekend days (Saturday and Sunday). The weekday count is simply the total minus the weekend count.

Worked Example

Using the default values: start date = January 1, 2024, end date = December 31, 2024.

  1. Convert both dates to timestamps: Jan 1, 2024 = 1704067200000 ms; Dec 31, 2024 = 1735603200000 ms.
  2. Difference = 1735603200000 − 1704067200000 = 31,536,000,000 ms.
  3. Divide by 86,400,000 ms/day = 365 days.
  4. January 1, 2024 is a Monday (weekday index 0). Using the weekend formula: floor((365 + (0+1)%7)/7) = floor(366/7) = 52. Multiply by 2 = 104 weekend days.
  5. Weekdays = 365 − 104 = 261.

The calculator displays: Total days = 365, Weekdays = 261, Weekends = 104.

How the Calculation Works

Dates are internally represented as timestamps—the number of milliseconds since January 1, 1970, UTC. The difference between two timestamps gives the exact elapsed time. For date-only inputs, the time is set to midnight (00:00:00) of that date, so the difference is always a whole number of days. This method is consistent across all browsers and systems because it follows the ECMAScript standard.

One subtlety: if you enter a start date and an end date that are the same day, the result is 0 days. This is because the calculator counts the number of midnights between the two dates, not the number of days you are “on� those dates. For example, from Monday to Tuesday is 1 day, not 2.

When to Use This Calculator

This tool is useful for any situation where you need a precise day count:

  • Planning a project timeline: “How many days until the deadline?â€�
  • Counting down to a vacation, wedding, or exam.
  • Calculating billing cycles or subscription periods.
  • Determining the length of a rental or lease.
  • Measuring the age of something in days (e.g., how many days since a purchase).

The weekday/weekend breakdown helps if you’re estimating business days for shipping or work schedules.

Common Mistakes and Misconceptions

A frequent error is assuming that the day count includes both the start and end dates. For example, if you say “I’ll be away from June 1 to June 3,� you might think that’s 3 days, but the calculator returns 2 days (June 1→2 and June 2→3). If you need to include both endpoints, add 1 to the result.

Another mistake is mixing time zones. If you enter dates as strings, the calculator interprets them as local time. If you enter timestamps, they are UTC. Always use the date picker or the YYYY-MM-DD format to avoid off-by-one errors due to time zone shifts.

Leap years are handled automatically. February 29 exists in leap years, and the timestamp difference correctly accounts for the extra day. For example, from February 28, 2024 to March 1, 2024 is 2 days because 2024 is a leap year.

Limitations and Edge Cases

The calculator works for dates between roughly 1900 and 2100, but the underlying timestamp system supports a much wider range. If you enter a date outside the valid range, the result may be inaccurate or show an error. Also, the calculator does not account for daylight saving time changes—this is irrelevant for date-only calculations because the difference is measured in whole days, not hours.

If you need to count business days (excluding weekends and holidays), this calculator only removes weekends. It does not know about public holidays. For that, you would need a list of holidays specific to your country or region.

How to Read the Results

The main result, “Total days,� is the number of 24-hour periods between the two dates. A positive number means the end date is after the start date; a negative number means the end date is before the start date. The weekday and weekend counts are always positive and are derived from the absolute total, so they don’t have signs.

If you want to know “how many days until� a future date, set the start date to today and the end date to the target date. The result is the number of days you need to wait. For a countdown that includes today, add 1.

Frequently Asked Questions

How do I calculate days until a specific date?

Set the start date to today’s date and the end date to your target date. The calculator will show the total days. If you want to include today, add 1 to the result. For example, if today is March 1 and your event is March 3, the calculator shows 2 days, but you have 3 days including today.

What does “weekdays� mean in the result?

Weekdays are Monday through Friday. The calculator counts how many of those days fall within the range. It does not exclude holidays. For business-day calculations that account for holidays, you’ll need to subtract them manually.

Can I calculate days between two dates in different years?

Yes, the calculator works across any number of years. It correctly handles leap years and month lengths. For example, from December 31, 2020 to January 1, 2022 is 366 days because 2021 is not a leap year and 2020 is, but the difference is simply the sum of days in each year.

Why does the calculator show 0 days for same-day dates?

Because it counts the number of midnights between the two dates. From midnight of the start date to midnight of the end date is zero days if they are the same day. If you want to count the day itself, add 1.

Is the result affected by time zones?

No, because the calculator treats each date as midnight local time. The difference is always a whole number of days. However, if you manually enter timestamps, they are interpreted as UTC, which could cause an off-by-one if you’re not careful. Stick to the date format to avoid issues.

Can I use this for calculating age in days?

Yes, set the start date to the birth date and the end date to today. The total days is the age in days. Keep in mind that this is the number of complete days, not the number of birthdays passed.

Related

Formula used
in start | Start date | - | 2024-01-01 | 0
in end | End date | - | 2024-12-31 | 0
out total | Total days | days | (end - start) / 86400000 | 0
out weekdays | Weekdays | days | total - weekends | 0
out weekends | Weekends | days | floor((total + (start_weekday + 1) % 7) / 7) * 2 | 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.