Date Difference Calculator

Find the exact time between two dates — in days, weeks, months, years, hours, minutes, and seconds.

100% in your browser — nothing uploaded

Calculate the Exact Number of Days, Weeks, and Months Between Two Dates

About the Date Difference Calculator

This date difference calculator shows the exact time between any two dates. Pick a start and end date, and it instantly breaks down the gap into years, months, days, weeks, hours, minutes, and seconds. Results update live as you change either date.

The calculator uses true calendar math for the year-month-day breakdown — it accounts for varying month lengths and leap years, so "January 31 to February 28" correctly counts as one month. Total days, hours, minutes, and seconds are computed from the exact millisecond difference.

Date difference formulas in Excel, Google Sheets, and SQL

Spreadsheets and SQL databases have built-in date arithmetic that makes it easy to compute differences between dates.

Excel / Google Sheets (A2 = start, B2 = end):
Total days: =B2-A2
Total weeks: =INT((B2-A2)/7)
Years + months + days: =DATEDIF(A2,B2,"Y") & " years, " & DATEDIF(A2,B2,"YM") & " months, " & DATEDIF(A2,B2,"MD") & " days"

Google Sheets only:
=DAYS(B2,A2)        — total days
=DAYS360(A2,B2)     — days using 360-day year (finance)
DATEDIF is undocumented in Excel but works. Google Sheets documents it officially.
-- PostgreSQL
SELECT end_date - start_date AS total_days,
       AGE(end_date, start_date) AS breakdown
FROM events;
-- AGE returns an interval like "1 year 2 mons 15 days"

-- MySQL
SELECT DATEDIFF(end_date, start_date) AS total_days,
       TIMESTAMPDIFF(MONTH, start_date, end_date) AS total_months
FROM events;

-- SQL Server
SELECT DATEDIFF(DAY, start_date, end_date) AS total_days,
       DATEDIFF(MONTH, start_date, end_date) AS total_months
FROM events;
Each database has its own date-diff functions — PostgreSQL's AGE() is the closest to a full breakdown.

FAQ

How does the year-month-day breakdown work?

It counts full calendar years first, then full months, then remaining days. This means "March 15 to June 15" is exactly 3 months and 0 days, while "March 15 to June 20" is 3 months and 5 days. Month-end edge cases like January 31 to February 28 are handled correctly.

Does it account for leap years?

Yes. The calculator uses JavaScript's built-in Date object, which correctly handles leap years. February 28, 2024 to February 28, 2025 is 366 days (2024 is a leap year), while the same span in non-leap years is 365 days.

Can I calculate the difference between a future date and today?

Yes. Set the start date to today and the end date to any future date. The calculator works with any two dates — past, present, or future — in either direction.

Related tools