Date Difference
Calculate the number of days, weeks and months between two dates.
How date differences are calculated
Computers store dates as the number of milliseconds since January 1, 1970 (Unix epoch). To find the difference between two dates, you subtract their millisecond timestamps, then convert to the desired unit. This approach automatically handles different month lengths and leap years β no manual calendar checking required.
Days = |Date B (ms) β Date A (ms)| Γ· 86,400,000
Weeks = Days Γ· 7
Months β Days Γ· 30.4375 (average month = 365.25 Γ· 12)
Years β Days Γ· 365.25 (accounts for leap years)Common date difference use cases
Leap years and their effect on date arithmetic
A leap year has 366 days instead of 365. Leap years occur in years divisible by 4, except century years must also be divisible by 400. (2000 was a leap year; 1900 was not.) When calculating differences spanning multiple years, using 365.25 as the average year length accounts for this correctly.
Leap year rule:
Divisible by 4? β candidate
Divisible by 100? β NOT a leap year (unlessβ¦)
Divisible by 400? β IS a leap year
Leap years: 2000 β, 2004 β, 2024 β, 2100 β, 2400 β
Impact on date differences:
Jan 1, 2023 β Jan 1, 2025 = 730 days (no leap year in range)
Jan 1, 2023 β Jan 1, 2025 actually = 730 days (2024 has 366: 365+366=731... split varies by start date)Days vs. months vs. years: when each matters
| Unit | Best for | Caution |
|---|---|---|
| Days | Payment terms, deadlines, subscriptions, legal periods | Unambiguous β always the safest unit for contracts |
| Weeks | Project sprints, recurring events, employee rotas | Divide days by 7; partial weeks are common |
| Months | Billing cycles, lease durations, age approximations | Months vary (28β31 days) β use days for legal precision |
| Years | Age, investment horizon, long-term planning | Use 365.25 days/year to account for leap years correctly |
Frequently asked questions
How do I calculate the number of days between two dates?
Enter a start and end date and the tool counts the calendar days between them, including a breakdown in weeks and months.
Does it include both the start and end date?
By default it counts the gap between the dates. If you need to include both endpoints (inclusive count), add one to the result.
Can I use it to count down to an event?
Yes. Set today as the start and your event as the end date to see exactly how many days remain.
Does it handle leap years correctly?
Yes. It uses the real calendar, so February 29 is included in any range that spans it.
Calculates the exact number of days between any two dates. Also converts to weeks, months and years. Useful for project timelines, deadlines, anniversaries and contracts.
Days = |date2 β date1| in milliseconds Γ· 86,400,000