Skip to main content

Date Difference Calculator

Find the exact number of days, weeks, months, and years between any two dates.

Time Between Dates

242 days

0 years, 7 months, 30 days

34

Weeks

7

Months

5,808

Hours

348,480

Minutes

What is Date Difference?

Working out the gap between two dates looks trivial until you try to say what the answer means. Is a span of 30 days "one month"? Is 1 January to 31 January thirty days or thirty-one? The arithmetic is easy; the conventions are what people get wrong.

The number of days between two dates is unambiguous, which is why it is the headline figure here. Every other unit — weeks, months, years — is a rounded interpretation of that same span, and months are the awkward one because they are not a fixed length.

The practical use cases are mostly deadlines and anniversaries: how long until a contract expires, how many days a project ran, how old something is in a unit a form is asking for.

The formula — how to calculate Date Difference

Days = whole days from start to end Weeks = floor(Days ÷ 7) Months = whole calendar months elapsed Years = whole calendar years elapsed Breakdown = Y years, M months, D days (each remainder after the larger unit)
Whole calendar months
= counted by the same day-of-month, not by dividing days by 30
Remainder
= the breakdown subtracts each unit before measuring the next, so the parts do not double-count

Months are counted by calendar, not by average length. One month after 31 January is 28 February, because February has no 31st and the date clamps to the end of the month.

Step-by-step example

  1. 01From 15 March 2024 to 7 August 2026.
  2. 02Total days: 875.
  3. 03Whole years: 2 — from 15 March 2024 to 15 March 2026.
  4. 04From 15 March 2026, whole months to 7 August 2026: 4, taking you to 15 July 2026.
  5. 05From 15 July to 7 August: 23 days.
  6. 06So the span is 875 days, or 2 years, 4 months and 23 days.
  7. 07Note that 875 ÷ 365 is 2.4 years, which is the same span expressed as a decimal — a different and equally valid answer, but not the same thing as the calendar breakdown. Which one a form wants is worth checking.

Why months are the difficult unit

Days and weeks are fixed. A week is always seven days, so weeks are just division. Months are not: they run 28, 29, 30 or 31 days, and a "month" from the 31st has no obvious landing point in February.

The convention used here, and by most software, is to count by day-of-month. One month after 15 March is 15 April. One month after 31 January is 28 or 29 February, because there is no 31st — the date clamps to the end of the month.

That clamping is why month arithmetic is not reversible. One month after 31 January is 28 February; one month before 28 February is 28 January. You do not get back where you started, and this surprises people writing billing code.

If you need a span in months for something financial — an interest period, a lease — check which convention the contract uses. Some use exact calendar months, some use 30-day months, and over a year the two diverge by five or six days.

Inclusive or exclusive counting

The other place answers differ legitimately is whether both endpoints count.

If you take 1 to 5 June off work, that is five days of leave — inclusive counting, which includes both the first and last day. If you ask how many days are between 1 and 5 June, the answer is four — exclusive counting, the plain difference.

Neither is wrong. Payroll and leave systems almost always count inclusively; date arithmetic in software almost always subtracts. This page reports the plain difference, so add one if you are counting days off.

Legal deadlines have their own rules again, often excluding the day of the triggering event and including the last day, unless it falls on a weekend or holiday, in which case it rolls forward. If a filing deadline matters, read the rule rather than the calculator.

Leap years are already handled

A day count walks the real calendar, so 29 February is included when it exists. There are 366 days from 1 March 2023 to 1 March 2024 because 2024 was a leap year, and 365 the following year. Dividing by 365.25 to approximate this is unnecessary and slightly wrong.

Timezones and the midnight trap

A calendar date is not a moment in time. "7 August 2026" is a different 24-hour window in Tokyo than in Los Angeles, and software that treats a date as an instant will quietly shift it.

The specific trap: many systems parse a bare date string as midnight UTC. In any timezone west of Greenwich, that instant is the previous day locally, so a date entered as the 7th can be read back as the 6th. It is a one-day error that only appears for some users, in some timezones, which makes it unusually hard to spot.

This calculator parses dates as local midnight for that reason, so the dates mean what the picker showed.

Daylight saving adds a smaller wrinkle: a span crossing a clock change contains a 23-hour or 25-hour day. The day count is unaffected because it counts calendar days, but an hour count derived by multiplying days by 24 would be off by one hour. The hours here are measured from the actual elapsed time instead.

Common mistakes to avoid

  • Dividing days by 30 to get months. Over a year that drifts by about five days.
  • Forgetting whether the count should include both endpoints. Leave and payroll almost always do.
  • Treating a date as an instant, which shifts it by a day in western timezones.
  • Assuming month arithmetic is reversible. Adding then subtracting a month from the 31st does not return the 31st.
  • Using 365 days for a year when the span crosses a leap day.

Frequently asked questions

Sources & references

Written and fact-checked by the CalcProLabs Editorial Team. Read our calculation methodology and editorial policy.

Last updated