Excel’s DATEDIF formula does exactly what the name suggests: it instantly calculates the number of days, months, or years between two dates. Whether you’re tracking project timelines, scheduling appointments, or managing inventory dates, this function gives precise results without manual counting. You’ll only need a working Excel spreadsheet and the formula itself—no extra tools required.

What You'll Need

  • A working Microsoft Excel spreadsheet (Excel 2010 or later; older versions lack DATEDIF).
  • Two date values—either in cell references (e.g., A1 and B1) or as raw date inputs (e.g., Excel’s date serial numbers).
  • Basic keyboard navigation (selecting cells, typing formulas).

Step-by-Step

  1. Open your Excel sheet and prepare two cells with date values. For example:
    1. Enter the starting date in cell A1 (e.g., 1/1/2023).
    2. Enter the ending date in cell B1 (e.g., 3/15/2023).
  2. Type the formula into another cell (e.g., C1) to display days between them. Use this syntax:

    =DATEDIF(A1, B1, "D")

    • A1: The starting date cell.
    • B1: The ending date cell.
    • "D": Specifies "days" as the result type (use "M" for months or "Y" for years).
  3. Press Enter—Excel will return the day difference (e.g., 44). No action needed beyond this.

Alternative syntax (for those unfamiliar with DATEDIF): Use Excel’s built-in date difference formulas for whole-number days:

  1. Subtract the two dates: =B1-A1 (results in days as a decimal).
  2. Round up to whole days: =ROUNDUP(B1-A1, 0) (e.g., 44.0 for 44 days).

However, DATEDIF is preferred for non-decimal outputs (e.g., 44 days) or inclusive/exclusive logic.

Common Mistakes

  • Date range issues: Ensure both dates are valid (e.g., no #VALUE! errors). If dates are in text (e.g., "1/1/2023"), convert them to date format first by selecting the cells, right-clicking > Format Cells, then choosing the Date tab. This prevents string parsing errors.
  • Incorrect result type: For example, DATEDIF(A1,B1,"D") gives days *between*, not *inclusive* of both dates. To include both, use DATEDIF(A1+1,B1,"D") (adds 1 to the start date).
  • Non-sequential dates: DATEDIF assumes dates are in chronological order. Reverse the cells (e.g., DATEDIF(B1,A1,"D")) to handle it correctly.
  • #DIV/0! error: Occurs if one date is blank or invalid.

Tips

  • Dynamic dates: Drag the formula down to apply it to multiple date pairs. Edit the cell references (e.g., A1,B1) to match your range when doing so.
  • Time zones: DATEDIF treats dates as local time (Excel’s default). For UTC or cross-time-zone calculations, convert dates to serial numbers using DATE(YEAR, MONTH, DAY) or the YEAR, MONTH, DAY functions.
  • Edge cases: For dates like 12/31/2023 to 1/1/2024, DATEDIF returns 1 day (the leap second is skipped). To include leap seconds, use a VBA workaround or manually adjust.
  • Hidden dates: If dates are stored as hexadecimal (#A1), convert them to serial numbers first by pressing Ctrl+Shift+: to input them as dates.
  • Negative values: Dates in reverse order (e.g., future to past) yield negative results. Absolute value the result with =IF(ABS(DATEDIF(A1,B1,"D"))>0, DATEDIF(A1,B1,"D"), 0).

Troubleshooting

  1. #VALUE! error:
    1. Check for non-date inputs (e.g., text like "Jan 1"). Use =ISDATE(A1) to verify cell contents are dates.
    2. Format cells as dates (right-click > Format Cells > Date).
  2. #DIV/0! error:
    1. Ensure both dates are valid (not empty or future dates).
    2. If using VBA, check for undefined arguments in custom functions.
  3. Formula not updating:
    1. Press F9 to recalculate the sheet.
    2. Use =DATEDIF(A1, B1, "D")/1 to force a recalculation (the trailing 1 tricks Excel into recalculating).
  4. Results >31,536 days:
    1. Excel’s date range is limited to 1048576 days (Jan 1, 1900 to Dec 31, 9999). For dates outside this range, use =DATEDIF(YEAR(A1)>"1900", YEAR(B1)>"1900", "D") to handle them.

Frequently Asked Questions

How do I count days between dates if one or both dates are missing?

Use conditional logic like =IF(ISERROR(DATEDIF(A1,B1,"D")), "Missing Data", DATEDIF(A1,B1,"D")). Replace A1 and B1 with your actual cell references.

Why does DATEDIF sometimes return a fractional day?

If the dates are nearly identical (e.g., 12/31/2023 and 1/1/2024), Excel may return a fractional day due to time-of-day differences. Round the result to whole days with =ROUND(DATEDIF(A1,B1,"D"),0).

Can I use DATEDIF for dates spanning year/month boundaries?

Yes, but ensure the dates are sequential. For example, DATEDIF("1/1/2023", "12/31/2023", "D") correctly counts 364 days (2023 wasn’t a leap year).

What if I need to exclude weekends or holidays?

Use Excel’s WORKDAY function instead: =WORKDAY(B1, A1-1, holidays), where holidays is an array of date ranges.

How does DATEDIF compare to DATEDIFS for multiple date ranges?

DATEDIFS is a newer function (Excel 365+) for complex comparisons. Example: =DATEDIFS(A1, B1, C1, D1, "D") compares ranges A1:C1 to B1:D1. Older Excel versions use nested DATEDIFs.

Can I convert DATEDIF results to a readable date?

No, DATEDIF returns raw days. To display as a date, add to the start date: =A1 + DATEDIF(A1,B1,"D").