Date Difference
Find the exact difference between any two dates in years, months, days, weeks, and hours.
About the Date Difference Calculator
Calculating the exact number of days, months, or years between two dates requires accounting for leap years (divisible by 4, except century years not divisible by 400), varying month lengths (28-31 days), and for precise calculations, timezone and daylight saving transitions. This calculator handles all Gregorian calendar rules correctly using the browser's built-in date arithmetic.
Common uses for date difference calculations
- Age in years and months — exact time since a birth date
- Contract duration — days or months from start date to end date
- Deadline countdown — working days or calendar days to a fixed date
- Invoice payment terms — calculating 30/60/90 day due dates from invoice date
- Interest accrual — exact days between dates for daily interest calculations
Calendar days vs working days
Calendar days is the simple count of all days between two dates. Working days excludes weekends (and optionally public holidays). Working day calculations matter for contracts with notice periods, delivery timescales, legal deadlines, and financial settlement dates where weekends are non-business days.
Date arithmetic in programming
Every major programming language provides date arithmetic utilities. JavaScript's Date object, Python's datetime module, and SQL date functions all support adding days, months, and calculating differences. The key rule: always store dates and times in UTC, convert to local time only for display, and use the IANA timezone database for timezone-aware operations.
- JavaScript —
Math.round((d2-d1)/(1000*60*60*24))for days between dates - Python —
(date2 - date1).daysusing datetime.date objects - SQL —
DATEDIFF(end_date, start_date)in MySQL;end_date - start_datein PostgreSQL - Excel/Sheets —
=B1-A1formatted as number gives days between dates
Frequently Asked Questions
Math.round((d2-d1)/(1000*60*60*24)); in Python (d2-d1).days.new Date(date.getTime() + days * 86400000). In Python: date + timedelta(days=n). In Excel or Google Sheets: =A1+90 adds 90 days. Use the Days Until tool to find what date falls N days from today.