Formula Errors

Prevent Excel DATEDIF #NUM! Errors When the End Date Is Blank

Bushra ParveenBushra Parveen Nov 12, 2026 869 views

Question details

Calculate a project duration without showing a #NUM! error while the completion date is blank.

Prevent Excel DATEDIF #NUM! Errors When the End Date Is Blank
Product
Microsoft Excel DATEDIF function
Device & OS
not provided
Scenario
A worksheet calculates the duration between a project start date and a completion date that may not yet be entered.
Observed behavior
DATEDIF returns #NUM! when the formula is evaluated before a valid completion date is available.
Before you start

Confirm that the start date cell contains a real Excel date, such as the date in F5. Decide whether unfinished projects should display a blank result or another status message.

Solution 1Recommended

Wrap DATEDIF in IF to leave the duration blank until completion

Use this formula when the completion date is optional and unfinished projects should not show an error.

The IF function checks whether the end-date cell is empty before Excel evaluates DATEDIF. If J5 is blank, the formula returns an empty result; otherwise, it calculates the number of complete days.

1
Select the duration result cell

Click the cell where the project duration should appear, such as K5.

2
Enter the protected DATEDIF formula

Type =IF(J5="","",DATEDIF(F5,J5,"d")) and press Enter. Replace F5 with the project start-date cell and J5 with the completion-date cell.

3
Choose the required unit

Keep "d" for complete days, change it to "m" for complete months, or use "y" for complete years.

4
Fill the formula down

Drag the fill handle from the result cell down the duration column to apply the formula to additional project rows.

Wrap DATEDIF in IF to leave the duration blank until completion
Blank completion dates no longer cause #NUM!: The duration cell stays blank until a valid date is entered in J5.
Calculate project durations without formula errors

Use WPS Spreadsheet to calculate durations only after an end date is entered

WPS Spreadsheet supports IF and DATEDIF formulas, so you can keep project-duration cells blank until a completion date is available and calculate days, months, or years automatically afterward.

  1. 1. Open the project workbook: In WPS Office, select Spreadsheet and open your Excel .xlsx or .xls project tracker.
  2. 2. Select the duration column: Click the first duration result cell, such as K5, beside the start and completion dates.
  3. 3. Enter the guarded formula: Enter =IF(J5="","",DATEDIF(F5,J5,"d")) and press Enter.
  4. 4. Apply the formula to project rows: Drag the fill handle down the column to calculate completed projects while leaving unfinished rows blank.
Use IF with DATEDIF to avoid #NUM! for blank completion dates.Open, edit, and save Microsoft Excel .xlsx and .xls workbooks.Use familiar spreadsheet formulas and fill handles for project trackers.Maintain a clear duration column for completed and ongoing projects.
microsoft office alternative - wps office

Frequently Asked Questions

Why does DATEDIF return #NUM! when the end-date cell is empty?

DATEDIF requires valid start and end dates. When the end-date reference is blank, wrap the function with an IF check, such as =IF(J5="","",DATEDIF(F5,J5,"d")).

How do I calculate months instead of days with a blank end date?

Replace the unit argument "d" with "m": =IF(J5="","",DATEDIF(F5,J5,"m")). This returns complete months only after J5 contains a date.

Can I show text instead of a blank for an unfinished project?

Yes. Replace the second empty string with text, for example: =IF(J5="","In progress",DATEDIF(F5,J5,"d")).

Why do I still get #NUM! after entering a completion date?

Check whether the completion date is earlier than the start date. DATEDIF returns #NUM! if J5 is before F5; correct the dates or use an IF condition to flag the row.