Prevent Excel DATEDIF #NUM! Errors When the End Date Is Blank
Question details
Calculate a project duration without showing a #NUM! error while the completion 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.
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.
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.
Click the cell where the project duration should appear, such as K5.
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.
Keep "d" for complete days, change it to "m" for complete months, or use "y" for complete years.
Drag the fill handle from the result cell down the duration column to apply the formula to additional project rows.

Check that the completion date is not earlier than the start date
Use this check if #NUM! still appears after an end date has been entered.
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. Open the project workbook: In WPS Office, select Spreadsheet and open your Excel .xlsx or .xls project tracker.
- 2. Select the duration column: Click the first duration result cell, such as K5, beside the start and completion dates.
- 3. Enter the guarded formula: Enter =IF(J5="","",DATEDIF(F5,J5,"d")) and press Enter.
- 4. Apply the formula to project rows: Drag the fill handle down the column to calculate completed projects while leaving unfinished rows blank.

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.




