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
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. Keep the inputs visible and clearly labelled and the whole thing stays auditable — anyone who opens the file later, including you, can see at a glance exactly what feeds the result and change one assumption without hunting through the formula. The difference between a quick fix and a sheet you can trust is the extra minute you spend validating “no of days between two 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 workflow that saves repeating the same clicks every week, 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. One habit worth forming early: name the cells that hold your inputs, so the formula reads in plain language instead of a string of cell addresses. A reviewer — or you in three months — can then follow the logic without decoding what B7 and D2 were supposed to mean, which is most of what makes a sheet maintainable.
In Google Sheets
Everything above works in Google Sheets too. Excel and Sheets share the formula syntax used here; only the surrounding menus are arranged differently. That portability is deliberate — learn it once and it follows you between the two tools and across Windows and Mac. Nothing on this page is behind a login: the tool runs entirely in your browser, the formula is shown in full with one-click copy, and the steps work the same on Windows and Mac. That is the whole promise here — the exact answer, a way to prove it on your own numbers, and just enough context to make it stick. The short version of “no of days between two 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").