← All how-to recipes

How to calculate the number of days between two dates

✓ Verified in LibreOffice 25.8.7.3 ✓ Verified in Google Sheets (2026-08-30)

Find how many days (or months/years) fall between a start date and an end date.

The formula

AppFormulaNotes
Excel=DATEDIF(A2,B2,"d")Days. Use "m" for whole months, "y" for years. Or simply =B2-A2 for days.
Google Sheets=DATEDIF(A2,B2,"D")Same; Sheets accepts "D"/"M"/"Y".
LibreOffice Calc=DATEDIF(A2,B2,"d")Supported in all versions.

How it works

DATEDIF(start, end, unit) returns the difference in the chosen unit: "d" days, "m" months, "y" years. Jan 1 to Mar 1 2024 (a leap year) is 31 + 29 = 60 days. For plain days you can also just subtract: =end-start.

Verified, not just documented

We ran =DATEDIF(DATE(2024,1,1),DATE(2024,3,1),"d") in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned 60 — exactly the expected result. We then ran the same formulas in Google Sheets, executed 2026-08-30: a formula-only workbook goes into Google Drive, which converts it to a Sheet and recalculates every formula with Google’s own engine, and comes back out as .xlsx carrying the values Google computed. It returned 60 for the worked example, the same value LibreOffice produced. Both engines’ numbers on this page are executed results. The Excel formula follows Microsoft’s official documented syntax — we do not run Excel.

Functions used

DATEDIF — see full Excel, Google Sheets & LibreOffice compatibility for each.

Related recipes

Related comparisons