Number of Days Between Two Dates Excel

There are two ways to “number of days between two dates excel”: the quick way you copy and the durable way you understand. This page gives you both. The exact Excel answer is above; below, we build the small mental model that makes the fix stick, so the next variation of the same problem solves itself.

Exact answer

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.

On this page8

Syntax

=DATEDIF(start_date, end_date, unit)

Arguments

Argumentrequired / optionalDescription
start_daterequiredThe earlier date — the start of the period.
end_daterequiredThe later date — the end of the period; it must not be earlier than start_date.
unitrequiredThe unit in quotes: "d" days, "m" whole months, "y" whole years, plus "ym", "yd" and "md" for the leftover part.

Related functions

NETWORKDAYSWEEKDAY
▤Annotated stepsExcel
1

Put the earlier date in one cell and the later date in another, such as A2 and B2.

2

In the result cell type =DATEDIF( and click the start date, then a comma and the end date.

3

Type a comma and the unit in quotes: "y" for years, "m" for months, or "d" for days.

4

Close the bracket and press Enter; for an age, use =DATEDIF(A2, TODAY(), "y").

5

For a detailed breakdown, concatenate "y", "ym" and "md" results into one text string.

Ctrl+CthenCtrl+Shift+V⌘+Cthen⌘+Ctrl+VPaste values · WindowsMac

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 a legacy function kept so Excel can open older Lotus 1-2-3 workbooks. Microsoft documents it, but it is absent from Excel's Formulas ribbon function list and gives no autocomplete, so you type it in full. One caveat from that documentation: Microsoft advises against the "md" unit, which has known limitations and can return a negative number, a zero or a plainly wrong result — use it only where you can check the answer, and for a plain day count prefer =B2-A2 or =DAYS(B2, A2). 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. For “number of days between two dates excel”, the reliable version is a short checking loop, not just the first command that appears to work. Run it on a deliberately small range first, watch how the affected cells change, and only then apply the same setup to the full sheet. 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. That is what makes a workflow that saves repeating the same clicks every week useful in real work: repeatable, auditable, and not dependent on memory or luck.

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. Check the referenced cells, argument order and result type in your workbook. Start with the worked example before changing an input, then compare the changed result with the calculation you expected. An error value or a result of a different type is a reason to inspect the inputs and arguments.

In Google Sheets

Google Sheets support for this task has not been verified. Check the function, arguments and workflow in the target product before transferring the example. Matching formula notation does not establish identical behaviour. 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 and the detail above shows why it holds — so the next time a colleague asks, you can answer without reaching for search. For “number of days between two dates excel”, keep the input cells and the result visible while you check the formula in Excel. Follow the worked example and change one input at a time. The steps explain the workbook calculation; this page does not run a live calculator for that task.

Common mistakes

  • Putting the dates in the wrong order — start_date must be the earlier date, or DATEDIF returns a #NUM! error.
  • Expecting "d" to count only working days — DATEDIF counts every calendar day; for weekdays use NETWORKDAYS instead.
  • 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?

It is a legacy function kept for Lotus 1-2-3 compatibility, so Excel offers no autocomplete or wizard for it and you must type it in full. Microsoft does document it — and advises against the "md" unit, which can return a negative number, a zero or a wrong result.

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

On the way here you may have searched this as “excel countif between two numbers”, “excel formula for number of days between two dates”, “number of days between two dates excel formula” and “excel formula number of days between two dates” — it is all the same task, and this page is the single, complete answer to it.

Why do people search for this in so many different ways?

Because the same task has many names. “excel countif between two numbers”, “excel formula for number of days between two dates”, “number of days between two dates excel formula” all point at the one operation explained on this page, which is why they all lead here.