How to Calculate the Number of Days Between Two Dates
Calendar arithmetic, Julian day numbering, leap years, month length variations, and date intervals.
Why Counting Days Is Harder Than It Looks
Calculating the time elapsed between two calendar dates seems straightforward, but our Gregorian calendar contains numerous irregularities: months range from 28 to 31 days, and leap years introduce an extra day every four years (with century exceptions).
Whether planning project milestones, calculating event countdowns, managing legal deadlines, or tracking loan accrual, knowing how to accurately determine the exact day count is essential.
Inclusive vs. Exclusive Date Counting
Before performing date math, clarify whether your counting method is inclusive or exclusive:
- Exclusive Counting (Standard Interval): Counts the number of nights or completed 24-hour periods elapsed. From Monday to Friday is 4 days (Friday − Monday). This is the standard method used in software, banking, and hotel bookings.
- Inclusive Counting: Counts both the start date and end date as active days. From Monday to Friday inclusive is 5 days (Monday, Tuesday, Wednesday, Thursday, Friday). Common in vacation planning and court appearance windows.
Worked Example: Calculating Days Across Month Boundaries
Calculate the days from March 1, 2025 to March 15, 2025, and across months from March 15 to May 10, 2025:
Within Same Month:
March 15 − March 1 = 14 calendar days (exclusive).
Across Multiple Months:
- Days remaining in March: 31 − 15 = 16 days.
- Full days in April: 30 days.
- Days in May: 10 days.
- Sum: 16 + 30 + 10 = 56 calendar days.
The Computer Science Method: Julian Day Numbers
Modern software and astronomical algorithms avoid calendar quirks by converting any date into a continuous count of days known as the Julian Day Number (JDN). In Unix systems, dates are stored as seconds elapsed since January 1, 1970 UTC (Unix Epoch):
Dividing total elapsed milliseconds by 86,400,000 provides the exact fractional day difference regardless of time zones or calendar month irregularities.
Leap Year Rules You Must Keep in Mind
Whenever calculating date ranges spanning February, verify if a leap year is included:
- A year is a leap year if divisible by 4.
- However, century years (ending in 00) are not leap years unless divisible by 400.
- For example: 2000 was a leap year; 2024 and 2028 are leap years; but 2100 will have only 28 days in February.
Calculate Date Differences in Seconds
Skip manual month counting and calendar lookups with our free date utilities:
- Calculate total calendar days, weeks, and business days with our Date Difference Calculator.
- Add or subtract days from any anchor date using our Add or Subtract Days Tool.
- Find your exact chronological age with our Age Calculator.
Put This Into Practice
Skip manual calculation math and compute your numbers in seconds with our free, 100% private Date Difference Calculator.
Open Date Difference Calculator →