Date Difference Calculator — Days & Duration Between Two Dates
Calculate the exact duration between two dates in years, months, and days, plus total weeks / days / hours / minutes and business days. Optional time-of-day precision. 100% local.
Last updated:
Pick two dates to see the exact duration between them in years, months, and days, plus total weeks / days / hours / minutes and business days. Optional time-of-day precision for minute-level accuracy.
What is Date Diff?
A date difference calculator returns the exact duration between two moments in time. Simple-looking, but easy to get subtly wrong: dividing total days by 30.44 (average month length) or 365.25 (average year length) yields fractional results that don't match how a human would answer 'how long between January 15 and March 15?'. The correct approach — calendar borrowing — is what this page uses. Both dates are treated as local calendar days by default (or local wall-clock time when the 'Include time' toggle is on), and results are reported both as a natural language expression ('3 years, 5 months, 12 days') and as raw totals for each common unit.
How to calculate the duration between two dates
- 1Enter the 'from' date and the 'to' date. Order doesn't matter — the tool will flag reversed inputs.
- 2Toggle 'Include time' if you need hour / minute precision (defaults to daily precision).
- 3Read the primary result: the duration in years, months, and days, borrowed the way a human would compute it.
- 4Scroll down for the total time span in weeks, days, hours, minutes, seconds, and business days.
- 5Use the swap button to reverse the direction and the display will update instantly.
Use Cases
Project timeline planning
Given a start date and a deadline, how many business days do you have to work with? The 'business days' output answers that directly.
Contract / lease duration
Compute the exact length of a lease, employment period, or subscription — down to the day.
Anniversary math
How long have you been married? How long since you started this job? The calendar-level output matches how humans phrase these things.
Test fixtures for time-sensitive code
Verify that your date-diff library produces the same year/month/day breakdown as this reference implementation.
Code Examples
Calendar duration in vanilla JavaScript (simplified)
function calendarDuration(from, to) {
let years = to.getFullYear() - from.getFullYear();
let months = to.getMonth() - from.getMonth();
let days = to.getDate() - from.getDate();
if (days < 0) {
// Borrow days from the previous month of `to`
days += new Date(to.getFullYear(), to.getMonth(), 0).getDate();
months -= 1;
}
if (months < 0) {
months += 12;
years -= 1;
}
return { years, months, days };
}Using dateutil.relativedelta
from dateutil.relativedelta import relativedelta
from datetime import date
diff = relativedelta(date(2027, 3, 15), date(2024, 1, 5))
print(diff.years, diff.months, diff.days)Key Concepts
- Calendar borrowing
- When computing a duration, if the 'to' day-of-month is smaller than the 'from' day-of-month, one month is borrowed from the total. The borrowed month's day count depends on the specific month — that's why the naive 30.44-day average is wrong.
- Business days
- Monday through Friday, ignoring public holidays. Because holidays vary by country and jurisdiction, this tool does not deduct them — for payroll or SLA calculations, subtract them manually.
- DST transitions
- When 'Include time' is on and the interval crosses a daylight-saving transition, one specific day of that interval is 23 or 25 hours long in local time. Total hours reflects this; total days does not.
- Leap seconds
- JavaScript's Date API ignores leap seconds — the total-seconds count is off by up to ~30 seconds when spanning decades. For scientific timing accuracy, use a specialized library.
Tips & Best Practices
- ▸For scheduling code, prefer libraries like date-fns, luxon, or Temporal (once it ships natively). They handle timezone-aware arithmetic more safely than raw Date math.
- ▸The business-days count includes both the from and to date when they fall on a weekday. If you need exclusive counting (e.g. 'weekdays elapsed since'), subtract 1 from the reported total.
- ▸When spanning across February, remember: 'one month later' is not always exactly 30 days. Feb 15 + 1 month = Mar 15, which is 28 or 29 actual days.
- ▸For non-Gregorian calendars (Hebrew, Islamic, Chinese lunar), this tool is not the right choice — Gregorian is baked in.
Frequently Asked Questions
How is the calendar-level duration computed?
By subtracting year, month, and day components separately with human-style borrowing — the same way you'd age-compute in your head. This avoids the common off-by-one errors from dividing total days by 30.44 or 365.25.
Does 'business days' account for public holidays?
No. Business days count Monday through Friday only. Public holidays vary by country and jurisdiction, so this tool does not subtract them — that requires a country-specific holiday calendar. For payroll or SLA calculations, subtract holidays manually.
Can I include the time of day?
Yes. Toggle 'Include time' to switch both inputs to date + time, and the result will show hours, minutes, and seconds in the calendar breakdown.
Is my data uploaded to any server?
No. All calculation happens locally in your browser using the Date and Intl APIs. Nothing is transmitted.
Do daylight saving time transitions affect the result?
Marginally, when you enable 'Include time' — a DST-crossing day is 23 or 25 hours long in local time, so the 'total hours' count reflects that. Calendar-day counts and 'business days' are unaffected.
Related Tools
Timestamp Converter
Convert Unix timestamps to human-readable dates and vice versa. Supports seconds, milliseconds, ISO 8601, and timezone selection.
Timezone Converter
Convert any date and time between IANA time zones — UTC to EST, PST to Tokyo, Sydney to London. Correct DST handling, compare multiple zones side-by-side. 100% local.
Working Days
Count business (working) days between two dates. Customize your workweek (M-F, M-Sat, custom) and paste a list of holidays to exclude them. Also shows total days, weekend days, and calendar span. 100% local.
Age Calculator
Calculate your exact age in years, months, and days from a date of birth. Shows total weeks, days, hours, and minutes lived, plus the countdown to your next birthday. 100% local — nothing uploaded.
Cron Generator
Build cron expressions from a friendly UI — every N minutes, daily at HH:MM, weekdays only, weekly, monthly, yearly. Preview the next 5 runs and a plain-English description. 100% local.
ISO 8601 Duration
Parse ISO 8601 duration strings (P3Y6M4DT12H30M5S, PT1H30M, P2W) into human-readable form, or convert total seconds into a canonical ISO 8601 duration. 100% local — used by REST APIs, video metadata, and scheduling systems.