#NUM! error in Excel: what it means and how to fix it
#NUM! means a calculation has no valid answer: an IRR with no rate to find, a square root of a negative. Each cause and its fix, with a practice sheet.
DATEDIF counts the complete years, months or days between two dates: =DATEDIF(A2,B2,"y") is an age in whole years. Excel doesn't suggest it as you type, but it works all the same.
Available in Excel 2007 and later, Excel for the web and Google Sheets=DATEDIF(start_date, end_date, unit)| Argument | Required | What it means |
|---|---|---|
start_date | Yes | The earlier date. If it's after end_date, DATEDIF returns #NUM!. |
end_date | Yes | The later date: often TODAY(), or a fixed date in a cell. |
unit | Yes | What to count, in quotes: "y" complete years, "m" complete months, "d" days; "ym" the months left after the whole years, "yd" the days left after the whole years, "md" the days left after the whole months (unreliable, see below). Capitals work too. |
The birthday in July hasn't come yet on 10 March 2026, so the age is still the lower number.
| Row | A | B | C |
|---|---|---|---|
| 1 | Born | On | Age |
| 2 | 22 Jul 1991 | 10 Mar 2026 | 34 |
=DATEDIF(A2,B2,"y") → 34"m" counts only whole months: the 16th of the month hasn't come round again by 10 March, so the month that started on 16 February doesn't count yet.
| Row | A | B | C |
|---|---|---|---|
| 1 | Started | On | Months |
| 2 | 16 Sept 2024 | 10 Mar 2026 | 17 |
=DATEDIF(A2,B2,"m") → 17"y" gives the whole years and "ym" the months left over after them; joined with text, they read as a length of service.
| Row | A | B | C |
|---|---|---|---|
| 1 | Started | On | Service |
| 2 | 2 May 2019 | 10 Mar 2026 | 6 years, 10 months |
=DATEDIF(A2,B2,"y")&" years, "&DATEDIF(A2,B2,"ym")&" months" → 6 years, 10 monthsFrom 31 January to 1 March is one whole month and one day, but "md" returns a negative number. It works as if 31 January plus a month were 31 February, which runs on to 3 March, two days after the end date.
| Row | A | B | C |
|---|---|---|---|
| 1 | Start | End | md |
| 2 | 31 Jan 2026 | 1 Mar 2026 | -2 |
=DATEDIF(A2,B2,"md") → -2DATEDIF with "m" counts the whole months, EDATE moves the start date on by that many, and what's left until the end date is the extra days.
| Row | A | B | C |
|---|---|---|---|
| 1 | Start | End | Days |
| 2 | 31 Jan 2026 | 1 Mar 2026 | 1 |
=B2-EDATE(A2,DATEDIF(A2,B2,"m")) → 1New data, so you can't copy the answer above. We check the number your formula returns, then change the data to make sure it still holds.
Your task: In C2, work out how many complete months the employee has worked, from the start date in B2 to the date in E2.
Graded live| Row | A | B | C | D | E |
|---|---|---|---|---|---|
| 1 | Employee | Started | Months | As of | |
| 2 | Lena | 14 Aug 2023 | 10 Mar 2026 |
Write the formula in the bar above, then press Check or Enter.
DATEDIF takes the start date (B2), the end date (E2) and the unit "m".
=DATEDIF(B2,E2,"m") Any formula that returns the same result passes.
From 15 January 2023 to 10 March 2026, as Excel counts them:
| Unit | What it counts | Result |
|---|---|---|
"y" |
Complete years | 3 |
"m" |
Complete months | 37 |
"d" |
Days | 1150 |
"ym" |
Months left after the whole years | 1 |
"yd" |
Days left after the whole years | 54 |
"md" |
Days left after the whole months | 23 |
Here every unit gives the count you’d expect. "yd" can be a day out when a 29 February falls between the two dates’ month and day in one year but not the other, because Excel counts "yd" as if both dates were in the start date’s year. "md" goes wrong more often: whenever the end date’s day is lower than the start date’s and the month before the end date is too short to hold the start date’s day, as with a start on 29, 30 or 31 January and an end date early in March.
=DATEDIF(A2,TODAY(),"y") with the date of birth in A2. It counts complete years only, so the age stays the lower number until this year's birthday comes round.
Excel keeps it for older workbooks and leaves it out of its suggestions and its function list. It still works: type it in full.
The start date is later than the end date, or the unit isn't one DATEDIF knows. Put the earlier date first and check the unit's spelling.
=B2-A2 gives the number of days, the same as "d". For whole months or years, use DATEDIF: dividing the days by 30 or 365 drifts.
Worked problems with practice sheets.
#NUM! means a calculation has no valid answer: an IRR with no rate to find, a square root of a negative. Each cause and its fix, with a practice sheet.
Practise DATEDIF and the functions around it in a live grid that grades your result and explains your mistakes.
Runs in your browser · Graded on your result · No install