Date Difference Calculator Online Free
Find the exact number of days, weeks, months, and years between any two dates. See it broken down in every unit, with a clear summary you can copy.
Two ways to measure the gap between two dates, and why they disagree
Ask how far apart 15 January and 15 March are and you get two defensible answers. Two months. Or 59 days. Both are right. They measure different things, and mixing them up is where date arithmetic quietly goes wrong in contracts, invoices and project plans.
This tool computes both at once, side by side, so you can see the relationship instead of guessing which one your spreadsheet gave you.
The calculation, line by line
The tool normalises both inputs to local midnight, orders them so the earlier date comes first, then runs two independent passes.
Note the round rather than floor on total days. That is deliberate. Daylight saving transitions make some local days 23 or 25 hours long, and flooring would silently drop a day whenever a spring clock change falls inside your range. Rounding absorbs the one hour wobble.
What each output actually counts
| Output | How it is derived | Exact |
|---|---|---|
| Days | Millisecond gap divided by 86,400,000, rounded | Yes |
| Weeks | Total days divided by 7, two decimals | Yes |
| Hours | Millisecond gap divided by 3,600,000 | Yes, in absolute terms |
| Minutes | Millisecond gap divided by 60,000 | Yes |
| Seconds | Millisecond gap divided by 1,000 | Yes |
| Months | Whole months from the walk, plus leftover days over 30.44 | Approximate |
| Years | Millisecond gap over 365.25 days, three decimals | Approximate |
Inclusive versus exclusive counting
This is the single biggest source of off by one arguments in date maths. From Monday to Friday is four days if you count the gaps, five days if you count the days themselves.
- Exclusive, what this tool doesCounts the elapsed interval. Start date is day zero. Standard for age, tenure, elapsed time and most software date libraries.
- Inclusive, add oneCounts both endpoints. Standard for hotel nights billed as days, hire periods, prison sentences and many statutory notice periods. If you need this, add one to the day total.
- Half open rangesDatabases and most APIs treat ranges as start inclusive, end exclusive. A booking from the 1st to the 4th occupies three nights. This matches the exclusive count exactly.
The leap year counter
The tool scans every year touched by your range and applies the full Gregorian rule, not the simplified one.
The century exception exists because the solar year is 365.2422 days, slightly under the 365.25 that a plain every fourth year rule assumes. Skipping three leap days per four centuries corrects the drift. Pope Gregory XIII introduced this in 1582, and it is accurate to about one day in 3,200 years. Note that many older spreadsheets, including Excel, deliberately treat 1900 as a leap year to stay bug compatible with Lotus 1-2-3, so date maths before March 1900 can be off by a day.
Lunar cycles
Total days divided by 29.53, the mean synodic month. That is the average interval between successive new moons. Individual cycles swing between roughly 29.27 and 29.83 days because the Moon’s orbit is elliptical and the Earth is moving around the Sun at the same time, so treat the figure as an average rather than a count you could verify against a specific sky.
Doing the same thing elsewhere
- Excel and Google Sheets:
=B1-A1gives days.DATEDIF(A1,B1,"y"), then"ym"and"md", reproduce the calendar breakdown. DATEDIF is undocumented in the Excel function list but works in every version. - SQL: PostgreSQL supports
AGE(end, start)for the calendar breakdown and plain subtraction for days. MySQL uses TIMESTAMPDIFF. - Python: dateutil.relativedelta gives years, months and days. The built in
timedeltagives only days and below, by design. - JavaScript: date-fns intervalToDuration or Luxon diff. The upcoming Temporal.Duration handles both modes natively.
- Format reference: ISO 8601 also defines duration notation such as
P1Y2M5D, which is worth using when you store an interval rather than a pair of dates.
Where people use this
Contract terms and notice periods, employee tenure and probation windows, warranty and returns eligibility, loan and interest day counts, project schedule variance, visa validity windows, medical follow up intervals, and reconciling two systems that report the same period differently. If you have ever had a finance system and a HR system disagree about length of service by one day, inclusive counting was almost certainly the culprit.
Questions About Date Difference Calculator Online Free
The tool subtracts the earlier date from the later date to get the total milliseconds between them. From that it derives the total days, weeks, hours, minutes, and seconds. The exact breakdown in years, months, and days is calculated separately by walking the calendar — subtracting year by year and month by month — so the remainder is always precise and accounts for different month lengths.
Yes. The total days count is based on exact millisecond differences, so February 29 is treated as a real day whenever it falls within the range. The years and months breakdown also handles this correctly because it walks the actual calendar rather than multiplying by a fixed 365.25 days. The extras panel also shows how many leap years fall within your date range.
Total days is the raw count of every calendar day between the two dates. The years, months, and days breakdown shows the same span expressed as a human-readable remainder — the way you would say someone is “3 years, 2 months, and 11 days old” rather than “1,167 days old”. Both figures are accurate; they just represent the same duration in different ways.
Yes. Enter any two dates regardless of order. If the start date is later than the end date, the tool automatically swaps them internally and still returns the correct difference. You can also use the swap button to reverse them yourself. There is no restriction on date range — calculate the gap between historical dates hundreds of years apart or future dates years ahead.
Hit “Set end date to today” to set the start date to today’s date, then change the end date to your target future date. The result shows exactly how many days, weeks, or months remain. Switch to the Days unit for a clean countdown number. The tool updates live as you change either date, so you can adjust the target and see the count shift immediately.
From the blog
Date and time, explained properly
Longer write ups on the calendar problems these tools solve, from ISO week numbering to scheduling across time zones.