Function Problems

How to Use DATEDIF Without Showing Zero for Missing Dates in Excel

Amos GikundaAmos Gikunda Oct 29, 2026 868 views

Question details

The user wants to calculate the difference between two dates using the DATEDIF function but needs the formula to return a blank cell instead of zero if one or both of the required dates are missing.

How to Use DATEDIF Without Showing Zero for Missing Dates
Product
Spreadsheet
Device & OS
not provided
Scenario
Calculating date differences (such as age or project duration) using DATEDIF in a dataset that contains incomplete or missing date entries.
Observed behavior
When a referenced date cell is empty, the standard DATEDIF function evaluates the blank cell as a zero, resulting in inaccurate '0' outputs instead of leaving the calculation cell cleanly blank.
Before you start

Ensure that the cells you are referencing for your start and end dates are properly formatted as 'Date' rather than 'Text', and identify the exact cell coordinates (e.g., W3 and D3) before writing your formula.

Solution 1Recommended

Wrap DATEDIF with IF and AND Functions

Use the IF and AND functions to verify that both date cells contain values before executing the DATEDIF calculation.

By default, spreadsheet software treats blank cells as zeroes during calculations. To bypass this, we can use the AND function to check if both the start date and end date are greater than zero. The IF function then dictates that if this condition is true, the DATEDIF calculation runs; if false (one or both dates are missing), it returns an empty string.

1
Select the target cell

Click on the cell where you want the calculated date difference or age to be displayed.

2
Enter the nested formula

Click into the Formula Bar at the top of the screen and type the nested formula. For example, if W3 is your earlier date and D3 is your later date, enter: =IF(AND(D3>0,W3>0),DATEDIF(W3,D3,"Y"),"")

3
Execute the calculation

Press the 'Enter' key on your keyboard. The cell will now remain blank if either date is missing, and will only show the calculated years if both dates are present.

4
Apply to multiple cells

Click the small square Fill Handle in the bottom-right corner of your selected cell, and drag it down to apply this updated formula to the rest of your column.

Wrap DATEDIF with IF and AND Functions
Customize the Output Unit: You can change the "Y" (Years) argument inside the DATEDIF function to "M" to calculate total months, or "D" for total days, depending on what kind of date difference you need to track.
Advanced Spreadsheet Features

Calculate Date Differences Flawlessly in WPS Spreadsheet

WPS Spreadsheet provides comprehensive support for complex logical tests and date functions, including IF, AND, and DATEDIF. You can effortlessly manage large datasets, calculate ages, and handle missing data without dealing with zero errors.

  1. 1. Open your dataset: Launch WPS Spreadsheet and open the workbook containing your incomplete date records.
  2. 2. Input the logical formula: Select the result cell, type =IF(AND(End_Date>0,Start_Date>0),DATEDIF(Start_Date,End_Date,"Y"),"") into the formula bar.
  3. 3. Calculate instantly: Press Enter to execute the function. WPS Spreadsheet will calculate valid date pairs perfectly while leaving missing data rows cleanly blank.
Fully compatible with Microsoft Excel formulas and file formats (.xlsx).Robust library of logical, date, and text functions for advanced data analysis.Clean, intuitive interface that makes formula auditing and editing easy.Free to download and use for your daily spreadsheet and data management tasks.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my DATEDIF formula return a #NUM! error?

The #NUM! error typically occurs when the start date is later than the end date. The DATEDIF function requires the older date to be listed first. Ensure your formula is structured exactly as DATEDIF(Earlier_Date, Later_Date, "Y").

Can I use IFERROR to hide the zero values from DATEDIF?

No. Returning a zero calculation from a blank cell is not recognized as a formula error by the software, so IFERROR will not be triggered. IFERROR only catches true errors like #VALUE! or #NUM!. You must use the IF and AND combination to test for blank cells.

How can I display text like 'Incomplete' instead of a blank cell?

You can easily customize the fallback value by replacing the empty double quotes at the end of the formula with your desired text. For example, use: =IF(AND(D3>0,W3>0),DATEDIF(W3,D3,"Y"),"Incomplete").

Will this IF and AND nested formula work normally in WPS Spreadsheet?

Yes, WPS Spreadsheet has full native support for DATEDIF, IF, and AND functions. Any formula structured this way in Excel will work identically and seamlessly in WPS Spreadsheet.