Cellwise Start free

Excel guide · 6 min read

DATEDIF not working in Excel: causes and fixes

Quick answerDATEDIF fails for a handful of reasons. #NUM! means the start date is after the end date (or the end date is blank), or the unit is not one of "y", "m", "d", "ym", "yd", "md". #VALUE! means a date is text Excel cannot read. #NAME? usually means the unit is missing its quotes. A result like 1/7/1900 is a right answer in a date format. And DATEDIF does work even though Excel never suggests it as you type.

Sample data

Every result on this page was calculated from this sheet by the same spreadsheet engine the Cellwise app uses.

ABCDE
1EmployeeStart dateEnd dateAs of
2Ana RuizMar 15, 2019Nov 4, 2026Nov 4, 2026
3Ben OkaforSep 1, 2026Feb 12, 2024
4Cara Lin15.03.2019Nov 4, 2026
5Dev ShahJun 10, 2025
6Eli ParkJan 31, 2024Mar 1, 2024
7Fay MossAug 21, 2023Feb 6, 2026

Download this sheet as an Excel practice file (.xlsx)

Quick diagnosis checklist

Match what you see to the cause, then jump to that section:

#NUM!: start date after end date, an empty end date, or a unit Excel does not know ("years", "w", "m " with a space). #VALUE!: a date stored as text that Excel cannot read with your regional settings. #NAME?: the unit typed without quotes, or the function name misspelled. A date like 1/7/1900 instead of 7: the cell has a date format. No tooltip or autocomplete: normal for DATEDIF, keep typing.

The sheet is a staff list with start and end dates, and one problem per row. Ana's row works, so it is the reference. Her 15 Mar 2019 to 4 Nov 2026 is 7 complete years, 91 complete months and 2,791 days.

=DATEDIF(B2,C2,"y")

Result: 7

7: Ana's complete years of service. Every other row breaks for a different reason.

#NUM!: the start date is after the end date

DATEDIF(start_date, end_date, unit) needs the earlier date first. It never returns a negative number; it returns #NUM! instead. Ben's row has the columns swapped: a start of 1 Sep 2026 and an end of 12 Feb 2024. Plain subtraction, =C3-B3, gives -932, and the minus sign is the clue.

If you only need the gap and the order does not matter, sort the two dates with MIN and MAX. If a backwards row means a data-entry mistake, flag it instead: =IF(B3>C3,"Check dates",DATEDIF(B3,C3,"y")) shows Check dates so the row gets fixed rather than hidden.

=DATEDIF(B3,C3,"y")

Result: #NUM!

#NUM!, because 1 Sep 2026 is after 12 Feb 2024. =DATEDIF(MIN(B3,C3),MAX(B3,C3),"y") returns 2 (and 30 with "m").

#NUM!: the end date is blank

Dev is still employed, so his end date is empty. An empty cell counts as 0, which comes before any real date, so the start is after the "end" and you get #NUM! again. This is the most common cause in HR and project sheets.

Use today's date when the end is missing. In a live sheet write IF(C5="",TODAY(),C5) as the end date. Here an as-of date in E2 (4 Nov 2026) stands in for TODAY so the example stays fixed.

=DATEDIF(B5,IF(C5="",$E$2,C5),"m")

Result: 16

16 complete months from 10 Jun 2025 to 4 Nov 2026. With "y" it is 1.

#VALUE!: the date is text

Cara's start date came from a European export as 15.03.2019. It looks like a date but it is text (ISTEXT(B4) is TRUE), and Excel set to US-style dates cannot read dots, so DATEDIF returns #VALUE!. Text that Excel can read, such as 2019-03-15, is converted on the fly and works, which is why the error shows up on some rows and not others.

The lasting fix is to convert the column: select it, Data > Text to Columns, click Next twice, choose Date: DMY and Finish. For a formula fix, rebuild the date from its pieces with DATE.

=DATEDIF(DATE(RIGHT(B4,4),MID(B4,4,2),LEFT(B4,2)),C4,"y")

Result: 7

7: DATE turns "15.03.2019" into 15 Mar 2019, and DATEDIF works again.

#NAME? or #NUM!: the unit is wrong

The unit must be text in quotes and one of six codes: "y" (complete years), "m" (complete months), "d" (days), "ym" (months left after the years), "yd" (days left after the years) and "md" (days left after the months). Case does not matter, so "Y" works too.

Without quotes, Excel reads y as a name it does not know and returns #NAME?. Anything else in quotes, such as "years", "w" or "m " with a trailing space, returns #NUM!. There is no week unit: use =INT((C2-B2)/7) for complete weeks, 398 for Ana.

=DATEDIF(B2,C2,y)

Result: #NAME?

#NAME?: the unit needs quotes. =DATEDIF(B2,C2,"y") returns 7.

The result shows as a date like 1/7/1900

If you type DATEDIF into a cell that was formatted as a date, or next to date columns, Excel may keep a date format. The answer 7 then shows as 1/7/1900, because day 7 of Excel's calendar is 7 Jan 1900. The formula is right; the format is wrong.

Select the cell and choose Home > Number Format > General (or press Ctrl+Shift+~). The same fix applies to =C2-B2, which can show a date instead of 2,791 days.

=DATEDIF(B2,C2,"y")

Result: 7 shows as 1/7/1900 with the custom m/d/yyyy format

7, which a date format displays as 1/7/1900.

"md" gives odd or negative days: use EDATE instead

For "7 years, 7 months, 20 days" people often combine "y", "ym" and "md". Microsoft's own documentation warns that "md" can return a negative number, a zero or an inaccurate result, and it goes wrong around month ends, like Eli's 31 Jan 2024 to 1 Mar 2024. Do not trust it for end-of-month dates.

A safer way to get the leftover days: add the complete months to the start with EDATE, then subtract that from the end. For Eli, DATEDIF "m" gives 1 month, EDATE(B6,1) lands on 29 Feb 2024 (EDATE moves to the last day when the month is shorter), and 1 Mar minus 29 Feb is 1 day. For Fay's row the full formula gives 2 years, 5 months, 16 days.

=DATEDIF(B2,C2,"y")&" years, "&DATEDIF(B2,C2,"ym")&" months, "&C2-EDATE(B2,DATEDIF(B2,C2,"m"))&" days"

Result: 7 years, 7 months, 20 days

7 years, 7 months, 20 days for Ana.

No tooltip, and which function to use instead

DATEDIF is an old compatibility function. Excel still calculates it but does not show it in autocomplete, the argument tooltip or the Insert Function list, so it looks as if it does not exist. Type the whole formula yourself, with the start date first.

You often do not need it. For days, =C2-B2 or =DAYS(C2,B2) both give 2,791 and show a negative number instead of an error when dates are swapped. Watch DAYS: it takes the end date first, so =DAYS(B2,C2) gives -2,791. For years with decimals, YEARFRAC(B2,C2) is the documented function. Keep DATEDIF for complete years and months, where it is the simplest option.

=DAYS(C2,B2)

Result: 2791

2791 days, the same as =C2-B2 and DATEDIF with "d".

Common mistakes

Putting the end date first

DATEDIF wants start, end. DAYS wants end, start. Mixing them up gives #NUM! in DATEDIF and a negative number in DAYS.

Hiding #NUM! with IFERROR

IFERROR(DATEDIF(...),"") also hides swapped columns and missing end dates. Fix the blank end with IF(C2="",TODAY(),C2) and flag B2>C2 rows instead.

Trusting "md" for end-of-month dates

Use =End-EDATE(Start,DATEDIF(Start,End,"m")) for the leftover days.

Dividing days by 365 for years

Leap years drift the answer around anniversaries. DATEDIF with "y" counts real complete years.

FAQ

Why does DATEDIF return #NUM!?

The start date is later than the end date, the end date cell is empty, or the unit is not one of "y", "m", "d", "ym", "yd" or "md". Check the order first: =End-Start shows a negative number when the dates are swapped.

Why can't I find DATEDIF in Excel?

It is a hidden compatibility function. Excel does not list it in autocomplete or Insert Function, and it shows no argument tooltip, but it works in every current version. Type it in full.

Why does DATEDIF give #VALUE!?

One of the dates is text Excel cannot read as a date, often from an export with dots or a day-month order your settings do not use. Convert the column with Data > Text to Columns > Date, or rebuild the date with DATE.

Can DATEDIF return a negative number?

No. When the start is after the end it returns #NUM!. If you need a signed result in days, use =End-Start or DAYS(End,Start).

Can DATEDIF count weeks?

No, there is no week unit, and "w" returns #NUM!. Use =INT((End-Start)/7) for complete weeks.

Functions used

Related guides

Updated