Work out the difference between two dates as a calendar answer (1 year, 2 months, 3 days) and as totals of days, weeks, hours and business days. Months are counted on the calendar, so January 31 to February 28 is one month rather than 28 days.
Start: 2024-01-31 09:00
End: 2025-03-01 17:30 1 year, 1 month, 1 day, 8 hours, 30 minutes
Total days: 395 (plus 8h 30m)
Weeks and days: 56 weeks, 3 days
Business days: 283 (Mon to Fri) The calculator finds the largest number of whole months you can add to the start without passing the end, then counts the days left over. Months are always added to the original start date, never stepped one at a time, so the day of the month does not drift.
January 31 plus one month is February 28 (29 in a leap year), the same rule PostgreSQL, Temporal and most date libraries use. So January 31 to February 28 is exactly one month, and January 31 to March 1 is one month and one day.
A leap-day start reaches its first anniversary on February 28 of the next year. Four years later it lands on February 29 again. Totals in days are unaffected, since those are a straight count.
Off, Monday to Friday is 4 days, the way you count nights in a hotel. On, it is 5, the way you count days of annual leave or the days of a conference. Excel's NETWORKDAYS counts inclusively, so turn it on to match.
Switch Clock to UTC when every day must be exactly 24 hours. By default both dates are read in your browser's local time zone. The calendar breakdown and the day counts use calendar days, so a day is a day even when the clocks change. However, the hour, minute and second totals are real elapsed time. A range that crosses a daylight saving change in local time is therefore an hour shorter or longer than days times 24, and a note under the totals says so.
Business days are Monday to Friday and nothing else. Public holidays differ by country, region and sometimes employer, so the calculator does not subtract them; take them off by hand. To convert a moment between two named zones, use the time zone converter instead.
// Calendar difference in whole years, months and days (dates only, no time zone)
function diffYMD(start, end) { // "YYYY-MM-DD" strings, start <= end
const [y1, m1, d1] = start.split("-").map(Number);
const [y2, m2, d2] = end.split("-").map(Number);
const dim = (y, m) => new Date(Date.UTC(y, m, 0)).getUTCDate(); // m is 1-based here
const addMonths = (n) => {
const t = y1 * 12 + (m1 - 1) + n, y = Math.floor(t / 12), m = (t % 12) + 1;
return Date.UTC(y, m - 1, Math.min(d1, dim(y, m))); // clamp Jan 31 -> Feb 28
};
const endMs = Date.UTC(y2, m2 - 1, d2);
let months = (y2 - y1) * 12 + (m2 - m1);
if (addMonths(months) > endMs) months--;
const days = (endMs - addMonths(months)) / 86400000;
return { years: Math.floor(months / 12), months: months % 12, days };
}
console.log(diffYMD("2024-01-31", "2025-03-01")); // { years: 1, months: 1, days: 1 }
console.log(diffYMD("2023-01-31", "2023-02-28")); // { years: 0, months: 1, days: 0 }
// Total days: use UTC so a DST change cannot make a day 23 hours long
const days = (a, b) => (Date.parse(b + "T00:00:00Z") - Date.parse(a + "T00:00:00Z")) / 86400000;
console.log(days("2026-03-01", "2026-04-01")); // 31 Once Temporal is available in your runtime, Temporal.PlainDate.from(start).until(end, { largestUnit: "year" }) does the same calendar math.
<?php
$start = new DateTimeImmutable("2024-01-31");
$end = new DateTimeImmutable("2025-03-01");
$diff = $start->diff($end);
// 1y 0m 29d: PHP borrows days from the month before the end date,
// so a month-end start can come out differently from this tool (1y 1m 1d)
echo $diff->y, "y ", $diff->m, "m ", $diff->d, "d\n";
echo $diff->days, " days total\n"; // 395
echo $diff->invert ? "negative\n" : "positive\n";
// Business days, Monday to Friday, end date excluded
$count = 0;
foreach (new DatePeriod($start, new DateInterval("P1D"), $end) as $day) {
if ($day->format("N") < 6) $count++;
}
echo $count, " business days\n"; // 283
// Adding months overflows instead of clamping: Jan 31 + 1 month = Mar 2 (2024)
echo $start->modify("+1 month")->format("Y-m-d"), "\n";
echo $start->modify("last day of next month")->format("Y-m-d"), "\n"; // 2024-02-29 from datetime import date, timedelta
start, end = date(2024, 1, 31), date(2025, 3, 1)
print((end - start).days) # 395
# Business days, Monday to Friday, end date excluded
print(sum(1 for i in range((end - start).days)
if (start + timedelta(days=i)).weekday() < 5)) # 283
# The standard library has no month arithmetic. python-dateutil does,
# and it clamps to the end of the month the same way this tool does:
# from dateutil.relativedelta import relativedelta
# relativedelta(end, start) -> relativedelta(years=+1, months=+1, days=+1)
# date(2024, 1, 31) + relativedelta(months=1) -> date(2024, 2, 29) The calculator works from each date's year, month and day fields rather than from millisecond timestamps, so the breakdown never picks up a stray hour from a clock change. Only the hour, minute and second totals use real elapsed time, from your browser's time zone data or from UTC.
This tool follows the specifications below. Read them when you need the exact normative wording, for example to settle an edge case between two implementations.
Enter the Start and End dates and read Total days. The end date is not counted by default, so Monday to Friday is 4 days; tick Include end date to count it and get 5.
Months are added to the start date and clamped to the end of shorter months, so January 31 plus one month is February 28, or February 29 in a leap year. That makes January 31 to February 28 exactly one month.
Yes, Monday to Friday between the two dates. Public holidays are not subtracted, because they differ by country and region.
In local time, a range that crosses a daylight saving change contains a 23-hour or 25-hour day. Days are counted as calendar days and hours as real elapsed time, and a note under the totals points out the difference. Switch Clock to UTC for 24-hour days.
Yes. The Add or subtract section takes a date, an amount and a unit (Days, Weeks, Months or Years) and shows the resulting date with its weekday. Month and year steps clamp to the last day of the month when needed.
Turn a date into epoch seconds with the Unix timestamp converter, reformat it with the date converter, or move a meeting across zones with the time zone converter.