Days Between Dates
Calculate the total absolute number of days between two dates.
How to Use
Enter both dates
Select or type a 'From' date and a 'To' date in the two input fields.
Choose inclusive or exclusive counting
Toggle the mode based on whether both boundary dates should be counted in the total.
Read the total days
See the absolute number of days between the two dates, always shown as a positive value.
View weeks breakdown
See the total also expressed as complete weeks plus remaining days.
The Inclusive vs. Exclusive Interval Problem: Fencepost Math and Julian Day Numbers
Calculating the number of days between two dates introduces one of the most pervasive puzzles in computer science and commercial law: the fencepost error (also known as an off-by-one discrepancy). Deciding whether to include or exclude the start date, the end date, or both depends entirely on the operational domain.
The Fencepost Problem: Why Off-By-One Errors Occur
If you build a 10-meter fence with posts spaced 1 meter apart, you do not need 10 posts; you need 11 posts. Similarly, if an employee works a temporary contract from Monday morning to Wednesday evening:
- Exclusive Calculation (Mathematical Difference): Wednesday - Monday = 2 days. This represents the elapsed distance between the two time markers.
- Inclusive Calculation (Events & Presence): Monday + Tuesday + Wednesday = 3 days. Both the start date and the end date represent full days of active service.
Astronomical Precision: Scaliger's Julian Day Number (JDN)
To eliminate month-length inconsistencies and historical calendar changes, professional astronomers, navigators, and geodesy engineers calculate intervals using the Julian Day Number (JDN) system, invented by Joseph Justus Scaliger in 1583.
The JDN is a continuous integer count of days that have elapsed since Greenwich mean noon on Monday, January 1, 4713 BC (proleptic Julian calendar). Subtracting two Julian Day Numbers (JDN2 - JDN1) produces an absolute, mathematically verified day count that bypasses all leap year tables and timezone variations.
Standard Commercial Counting Conventions
| Industry / Domain | Default Convention | Legal & Practical Definition |
|---|---|---|
| Hotel & Hospitality Booking | Exclusive of Checkout Date | Hotels bill per "night" (staying Friday to Sunday equals 2 nights, even though guest is present across 3 calendar dates). |
| Equipment & Vehicle Rental | Inclusive of Both Days | Renting construction equipment from June 1st to June 3rd incurs 3 full daily rental charges if returned on the close of business. |
| Residential Real Estate Leases | Statutory Rule of Civil Procedure | Typically excludes day of service and includes final day of notice for statutory 30-day lease termination notices. |
| Maritime Shipping (Demurrage) | Running Days (Inclusive) | Laytime calculations penalize charterers for consecutive calendar days cargo sits in port, regardless of weekends or holidays. |
Real-World Examples & Use Cases
Event Planning and Countdown Tracking
Event planners calculating time until a wedding, conference, product launch, or holiday need a simple absolute day count. 'The wedding is 127 days away.' Project deadlines, subscription renewal reminders, and policy expiry dates are often expressed as 'N days from now' or 'N days apart'. The simple total-days format is more actionable for planning than a years/months/days breakdown for spans under a year.
Billing, Subscription, and Rental Period Calculations
Landlords calculating pro-rata rent for partial months, subscription services billing for exact days of service used, and daily-rate contractors invoicing clients use total-day counts for accurate billing. A contractor billed at $250/day who worked from March 15 to April 7 (inclusive) worked 24 days total. Pro-rata rent for a tenant who moved in March 17 and the month ends March 31 is 15 days × (monthly rent / 31 days).
Sports and Athletic Training Cycles
Athletes planning training cycles use day counts to structure periodization programs. A 16-week marathon training plan is 112 days. Tapering periods, peak training weeks, and recovery periods are specified in days from race day (T-14 days, T-7 days). Coaches and athletes tracking training blocks between competitions and performance tests use specific day intervals to structure progressive overload and recovery cycles precisely.
Academic Semester and Course Duration Tracking
Universities and online course providers calculate course durations in days for scheduling, accreditation documentation, and completion certificate dates. 'This 8-week course runs 56 calendar days.' Students planning study schedules divide total study days by chapters or topics. MOOC platforms calculate completion rates relative to the total number of days the course has been available. Academic sabbatical leave, research fellowship dates, and grant reporting periods are documented as specific day counts.
How It Works
Days between dates calculation: Core formula using UTC dates (avoids DST errors): const utcDate1 = Date.UTC(y1, m1-1, d1); const utcDate2 = Date.UTC(y2, m2-1, d2); const diffMs = Math.abs(utcDate2 - utcDate1); const diffDays = Math.floor(diffMs / (1000 × 60 × 60 × 24)); // This is the EXCLUSIVE count (start to end, not counting start or end) Inclusive count: inclusiveDays = exclusiveDays + 1; // Counts both the start day AND the end day Why UTC matters: Local time calculations can lose/gain an hour at DST transitions (e.g. March 8 to March 9 in US has only 23 hours in local time) Using UTC avoids this — UTC never has DST shifts Weeks and days breakdown: weeks = Math.floor(totalDays / 7); remainingDays = totalDays % 7; Result: N weeks and M days Example: From 2024-01-01 to 2024-04-01 (Jan 1 to Apr 1): Jan: 31 days, Feb: 29 days (2024 is a leap year), Mar: 31 days Total: 31 + 29 + 31 = 91 days exclusive
Frequently Asked Questions
What is the difference between inclusive and exclusive day counting?▼
Why do I get different answers with different tools?▼
How many days are in different common time periods?▼
Does the calculator work for historical dates before 1970?▼
How do I calculate days remaining until a future date?▼
Related Tools
Explore other tools in this category.
Age Calculator
Calculate your exact age in years, months, and days based on your date of birth.
Age in Days & Hours
Find exactly how old you are in years, months, weeks, days, hours, and minutes.
Countdown Timer
Set a custom countdown with hours, minutes, and seconds. Pause, resume, and use quick presets.
Timezone Converter
Convert any date and time between world timezones. Includes a live clock mode and multi-zone comparison.
Unix Timestamp Converter
Convert Unix timestamps to human-readable dates and vice versa. Shows a live current timestamp.
Date Difference Calculator
Find the exact chronological difference in years, months, and days between two historical or future dates.