How to Stop a DATEDIF Date Count at Month-End in Excel
Question details
The user needs to calculate the number of elapsed days updating daily, but automatically cap the count at the end of the month if the delivery date is left blank.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Tracking elapsed days for deliveries or tasks where the calculation needs to pause or stop at the end of the current month if no completion date is entered.
- Observed behavior
- A standard subtraction formula continues counting indefinitely, requiring a nested conditional formula using IF, TODAY, and EOMONTH to successfully cap the days.
Ensure your start and end date columns are properly formatted as Dates, and note the specific cell references for your delivery dates to adapt the formula correctly.
Use IF, TODAY, and EOMONTH Functions to Cap the Count
Combine logical conditions with the EOMONTH function to handle blank delivery dates and stop counting at month-end.
By combining the IF statement with MIN, TODAY, and EOMONTH, you can dynamically check if a delivery date is missing. If it is blank, the formula calculates the difference up to either today's date or the end of the month, whichever is earlier.
Click on the cell where you want the elapsed days to be displayed.
Enter the formula: =IF(B2="", MIN(TODAY(), EOMONTH(A2,0)) - A2, B2 - A2). In this example, A2 represents your start date and B2 represents your delivery date.
Press Enter to apply the formula. This logic checks if the delivery date (B2) is blank. If true, it subtracts the start date from the smaller value between today's date and the month's end date.
Click and drag the fill handle at the bottom-right corner of the cell down to apply the formula to the rest of the column.

Use DATEDIF Combined with Month-End Evaluation
If you specifically need to use DATEDIF to extract full days, you can embed the month-end check directly inside the DATEDIF arguments.
Calculate Complex Date Formulas Easily with WPS Spreadsheet
WPS Office Spreadsheet provides full support for advanced date and time functions, including DATEDIF, EOMONTH, and nested IF statements. You can easily manage project timelines and delivery calculations exactly as you would in Microsoft Excel.
- 1. Open your Spreadsheet: Launch WPS Office and open your workbook containing the delivery dates.
- 2. Apply the Formula: Select the target cell and input =IF(B2="",MIN(TODAY(),EOMONTH(A2,0))-A2,B2-A2).
- 3. Format as Number: Ensure the result cell is formatted as a Number rather than a Date by right-clicking the cell and selecting 'Format Cells'.
- 4. Drag and Fill: Use the fill handle at the bottom right corner of the cell to drag the formula down to other rows.

Frequently Asked Questions
Why does my DATEDIF formula return a #NUM! error?
The #NUM! error in DATEDIF usually occurs if the start date is greater than the end date. Ensure your formula logic doesn't result in a negative date difference, especially when using TODAY() or EOMONTH() in dynamic checks.
What does the 0 in EOMONTH(A2, 0) mean?
The second argument in the EOMONTH function specifies the number of months before or after the start date. A '0' means it will return the last day of the exact same month as the date located in cell A2.
Can I exclude weekends from my elapsed days calculation?
Yes. Instead of standard subtraction or DATEDIF, use the NETWORKDAYS function. You can combine it with EOMONTH, like this: =NETWORKDAYS(A2, EOMONTH(A2,0)) to ensure only working days are counted.
Why is the formula result showing as a date instead of a number?
Excel sometimes automatically applies Date formatting to cells containing date formulas. To fix this, right-click the cell, choose 'Format Cells', and change the format category to 'Number' or 'General'.




