How this calculation works
Compare two calendar dates in complete years, months and remaining days, alongside a signed total-day difference. Calendar units help describe an interval; total days help measure its fixed length. The calendar description is the gap’s magnitude, while the sign on total days and weeks indicates whether the end precedes the start.
Worked example
This example uses illustrative inputs. Your current result is shown above.
From 1 January 2024 to 1 March 2024, the gap is 0 years, 2 months, 0 days. January contributes 31 days and February contributes 29, so total days = 60 and whole weeks = floor(60/7) = 8.
Assumptions and limits
- The total is elapsed days, not a count including both endpoint dates.
- Calendar years and months vary in length and use end-of-month clamping.
- Dates contain no clock times; the elapsed-day calculation is not a measurement of local daylight-saving hours.
Questions people ask
What happens if the end date is earlier?
The calendar gap stays a nonnegative magnitude, but total days and whole weeks are negative. Swap the dates if you want forward totals.
How do I count both the first and last date?
For a forward inclusive count of dates, add one to the elapsed-day total. Business-day counting has its own start/end inclusion settings and holiday exclusions.