Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Excel DATEDIF Missing? Here's the Fix

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

If you type =DATEDIF( into Excel and nothing appears, or you get a #NAME? error, the function is not missing from your copy of Excel — it is hidden. DATEDIF is a legacy function from Lotus 1-2-3 that Microsoft kept for compatibility, but it is not listed in the Function Library, the Insert Function dialog, or the formula autocomplete list. The good news: it still works in every modern version of Excel (2010, 2013, 2016, 2019, 2021, and Microsoft 365) as long as you type the syntax correctly. This guide shows you exactly how to use DATEDIF, what to do when it returns an error, and how to calculate date differences without it if you prefer.

What You'll Need

  • A computer with Microsoft Excel installed (Windows or Mac). The steps are the same for both.
  • Two dates in separate cells, or two dates typed directly into the formula. Dates should be in a format Excel recognises, like 1/15/2025 or 15-Jan-2025.
  • Basic familiarity with typing formulas into a cell.

Step-by-Step

  1. Open your Excel workbook and navigate to the worksheet where you want the result.
  2. Click on an empty cell where you want the date difference to appear.
  3. Type the DATEDIF formula manually. Because DATEDIF is hidden, you must type the full function name yourself. The syntax is:
    =DATEDIF(start_date, end_date, unit)
    For example, if cell A1 contains 1/1/2024 and cell B1 contains 12/31/2024, type:
    =DATEDIF(A1, B1, "Y") to get the number of complete years (0 in this case, because the dates are within the same year).
  4. Choose the unit code that matches what you want to calculate. The unit is a text code that must be enclosed in double quotes:
    — "Y" gives the number of complete years.
    — "M" gives the number of complete months.
    — "D" gives the number of days.
    — "YM" gives the number of months remaining after the last full year (e.g., from 1/1/2024 to 6/15/2025, this returns 5).
    — "YD" gives the number of days remaining after the last full year (ignores years).
    — "MD" gives the number of days remaining after the last full month (ignores months and years).
  5. Press Enter to see the result. If you typed everything correctly, you will see a number. If you see #NAME?, check that you spelled DATEDIF exactly and that the unit is in quotes.
  6. Copy the formula down if you have multiple rows of dates. Click the small square at the bottom-right corner of the cell and drag it down to fill the column.

Note: The menu labels and function names are consistent across Excel versions, but the exact wording of dialog boxes may vary slightly between Windows and Mac, and between older and newer releases. The steps above work in all current versions.

Common Mistakes

  • Typing the unit without quotes. DATEDIF requires the unit to be a text string. =DATEDIF(A1,B1,Y) will give a #NAME? error. Always use "Y", "M", etc.
  • Reversing the start and end dates. DATEDIF expects the start date to be earlier than the end date. If you swap them, Excel may return a #NUM! error (or in some versions, a negative number). Always put the earlier date first.
  • Using dates stored as text. If your dates are actually text strings (e.g., "January 1, 2024" as text), DATEDIF will return #VALUE!. Convert them to real dates using the DATEVALUE function or by re-entering them as dates.
  • Expecting DATEDIF to appear in the function list. It won't. That's normal. You must type it manually.
  • Using the wrong unit code. For example, using "Y" when you want months. Double-check what each code returns.

Tips

  • Use DATEDIF for age calculations. To calculate someone's age in years, use =DATEDIF(birthdate, TODAY(), "Y"). This is more accurate than dividing days by 365.
  • Combine DATEDIF with other functions. For example, to get a text string like "3 years, 2 months", use:
    =DATEDIF(A1,B1,"Y") & " years, " & DATEDIF(A1,B1,"YM") & " months"
  • If you don't need the hidden function, use the simpler alternative. For days, just subtract the start date from the end date: =B1-A1 (format the cell as Number). For months, use =DATEDIF or =YEARFRAC if you need fractional years.
  • Remember that DATEDIF counts complete units. For example, from Jan 1 to Jan 31 is 0 complete months, not 1. If you need inclusive counts, add 1 to the day result.
  • Use the formula audit tools. If you get an unexpected result, click the cell and go to Formulas > Evaluate Formula to see how Excel computes it step by step.

Troubleshooting

If DATEDIF isn't working, follow these checks in order:

  1. Check for typos. The function name must be exactly DATEDIF (no spaces, no extra letters). A common mistake is typing DATEDIFF (with two F's) — that will give #NAME?.
  2. Verify the unit is in quotes. Look at your formula bar. It should show something like =DATEDIF(A1,B1,"D"). If you see D without quotes, add them.
  3. Ensure the dates are real dates. Select the date cells and check the Number Format in the Home tab. If it says "Text", change it to Date. Also, check if the cell contains a leading apostrophe (which forces text).
  4. Confirm the end date is later than the start date. If not, swap the references or use the ABS function to get an absolute value: =ABS(DATEDIF(B1,A1,"D")) — but note that DATEDIF may still error if the order is reversed, so it's safer to just reorder the arguments.
  5. If you get #NUM! for dates like Jan 31 to Mar 1 with unit "MD", that's a known quirk. The "MD" unit can return a negative number or an error because there is no 31st of February. In that case, use a different approach: =MOD(B1-A1, 30) or simply calculate total days and subtract whole months manually.
  6. If all else fails, test with simple dates. In a blank cell, type =DATEDIF(DATE(2024,1,1), DATE(2024,1,15), "D"). If that returns 14, DATEDIF works and the problem is with your data. If it errors, your Excel may have a problem — try restarting Excel or repairing Office.

Frequently Asked Questions

Why is DATEDIF not in the list of functions?

DATEDIF was included in Excel for compatibility with Lotus 1-2-3, and Microsoft never added it to the official function list. It still works, but you have to type it manually.

Can I use DATEDIF in Excel Online or Google Sheets?

Excel Online (the free web version) does support DATEDIF when you type it manually. Google Sheets also has a DATEDIF function with the same syntax, but it is listed there.

What is the difference between DATEDIF and YEARFRAC?

DATEDIF returns whole units (years, months, days). YEARFRAC returns a decimal representing the fraction of a year between two dates. For example, DATEDIF with "Y" might return 1, while YEARFRAC might return 1.5 for the same dates.

How do I calculate the difference in months between two dates?

Use =DATEDIF(start, end, "M") for complete months. If you want months including partial months, you can use =(YEAR(end)-YEAR(start))*12 + MONTH(end)-MONTH(start).

Why does DATEDIF return 0 for years when the dates are a year apart?

DATEDIF counts complete years. For example, from 1/1/2024 to 1/1/2025 is exactly one year, so it returns 1. But from 1/1/2024 to 12/31/2024 is 0 complete years because the end date is before the anniversary. If you need inclusive years, add 1 to the result.

Can I use DATEDIF with dates in different cells that contain formulas?

Yes, as long as the formula results are valid dates. DATEDIF works with any cell references that contain date serial numbers.