In Excel: use =DATEDIF(start_date, end_date, "d") — it returns the difference between two dates in the unit you ask for: "d" for days, "m" for whole months or "y" for whole years.
Syntax
Arguments
| Argument | Description | |
|---|---|---|
start_date | required | The earlier date — the start of the period. |
end_date | required | The later date — the end of the period; it must not be earlier than start_date. |
unit | required | The unit in quotes: "d" days, "m" whole months, "y" whole years, plus "ym", "yd" and "md" for the leftover part. |
Related functions
Breakdown: 0 years · 11 months · 30 days
Need it as an auditable file?
Ships inside the linked template — formula-driven, unlocked, audit-ready.
What this does
DATEDIF returns the gap between two dates measured in whole days, months or years, depending on a unit code you give in quotes. Beyond the basic "d", "m" and "y", three combination codes return only the remainder: "ym" the months ignoring whole years, "yd" the days ignoring whole years, and "md" the days ignoring whole months. It is most famous for age calculation — =DATEDIF(DOB, TODAY(), "y") gives a person's age in completed years. DATEDIF is an UNDOCUMENTED legacy function: it does not appear in Excel's function list and gives no autocomplete, but it works in every version. Notably the unit codes stay as the English letters "y", "m" and "d" even in German Excel. The same idea underpins a lot of everyday Excel work, so the few minutes spent getting it right here pay back across every sheet you build afterwards. Treat it as a pattern, not a one-off, and it stops being something you look up and starts being something you reach for. The difference between a quick fix and a sheet you can trust is the extra minute you spend validating “calculate number of days between dates in excel”. Start on a copy or a tiny sample, keep the affected cells visible, and compare the result with the tool above before you touch the real workbook. When a formula is involved, keep the inputs labelled beside it, reference cells instead of typing values, and apply number formatting only after the result checks out. The point is a calculation you can defend to a CFO or an auditor, but the practical win is that someone else can open the file and understand what happened without asking you.
A worked example
A start date 15/03/2020 sits in A2 and an end date 03/06/2026 in B2. =DATEDIF(A2, B2, "y") returns 6 (whole years), =DATEDIF(A2, B2, "m") returns 74 (whole months), and =DATEDIF(A2, B2, "d") returns 2271 (days). For an exact age string, combine units: =DATEDIF(A2, B2, "y") & " years, " & DATEDIF(A2, B2, "ym") & " months" returns "6 years, 2 months". For a live age, use TODAY() as the end date. DATEDIF is the simplest way to get a clean whole-number difference in years, months or days — the standard tool for ages, tenure and durations across every Excel version. A practical tip before you scale it up: build it once on a small block of test data, confirm the number against the tool on this page, and only then point it at your real sheet. That one habit catches almost every mistake while it is still cheap to fix, long before a wrong figure reaches a report or a colleague.
In Google Sheets
Google Sheets handles this almost identically to Excel. The formula syntax above is the same, and the menu lives under a slightly different label rather than a ribbon tab. Use the platform toggle at the top of the page to switch every keyboard shortcut between Windows and Mac, and expect at most cosmetic differences in naming. The aim was to get you unstuck fast and leave you a little more capable than a copy-paste would. The answer is at the top, the tool proves it, and the detail above shows why it holds — so the next time a colleague asks, you can answer without reaching for search. The short version of “calculate number of days between dates in excel”: the answer is at the top of this page, the tool proves it on your own numbers, and the sections above explain why it holds so the next variation does not stump you. Excel rewards people who reference cells instead of typing values and who keep inputs separate from formulas, because that is what makes a result you can audit months later. Build it once, deliberately, with the live tool as a check, and you convert a one-off lookup into a reusable skill — which is the whole point of learning the why and not just the what.
Common mistakes
- Putting the dates in the wrong order — start_date must be the earlier date, or
DATEDIFreturns a#NUM!error. - Expecting "d" to count only working days —
DATEDIFcounts every calendar day; for weekdays useNETWORKDAYSinstead. - Translating the unit codes in German Excel — they stay as the English letters "y", "m" and "d"; only the argument separator changes to a semicolon.
Frequently asked questions
Why is DATEDIF not in the function list?
DATEDIF is an undocumented legacy function kept for Lotus 1-2-3 compatibility, so Excel offers no autocomplete or wizard for it. You must type it in full, but it calculates correctly in every version.
How do I calculate age with DATEDIF?
Use the "y" unit with TODAY() as the end date: =DATEDIF(DOB, TODAY(), "y") returns the age in completed years. Add "ym" and "md" parts if you want years, months and days.
Do the unit codes change in German Excel?
No. The unit codes stay as the English letters "y", "m" and "d" even in a German installation; the function name also stays DATEDIF, and only the argument separator becomes a semicolon: =DATEDIF(A2; B2; "y").
Other ways people ask this
This is also commonly searched as “calculate number of days between dates excel” and “calculate the number of days between dates in excel”. They describe the identical operation, so you are in the right place no matter how you phrased it.
Why do people search for this in so many different ways?
Because the same task has many names. “calculate number of days between dates excel”, “calculate the number of days between dates in excel” all point at the one operation explained on this page, which is why they all lead here.