Calculation Issues

Return One Month Instead of 31 Days in an Excel Formula

Algirdas JasaitisAlgirdas Jasaitis Nov 25, 2026 869 views

Question details

Calculate a date range so a 31-day range returns 1 month and shorter ranges return their day counts.

Return One Month Instead of 31 Days in an Excel Formula
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet has start and end dates, such as March 31 and April 30, and needs a result based on the length of the range.
Observed behavior
The desired result is 1 for the 31-day range when both dates are counted, and the number of days for shorter ranges.
Before you start

Enter the start date in E17 and the end date in F17 as recognized Excel dates, with the end date on or after the start date. Decide whether to count both dates: March 31 through April 30 is 31 days inclusive, but 30 elapsed days.

Solution 1Recommended

Count both dates and return 1 for ranges over 30 days

Use this formula when the start and end dates both count toward the day total.

1
Enter the dates

Type the start date in E17 and the end date in F17.

2
Enter the formula

Select the result cell and enter =IF(DATEDIF(E17,F17,"d")+1>30,1,DATEDIF(E17,F17,"d")+1).

3
Check the result

Press Enter. March 31 through April 30 returns 1; a shorter inclusive range returns its day count.

Count both dates and return 1 for ranges over 30 days
This is a day-count rule: Every range over 30 inclusive days returns 1, even if it spans several months. The numeric result alone does not distinguish 1 month from 1 day.
Calculate date ranges in WPS

Calculate the same date-range result in WPS Spreadsheets

Use WPS Spreadsheets to enter the inclusive-day formula and return 1 for ranges over 30 days while keeping shorter day counts.

  1. 1. Open your spreadsheet: Open WPS Spreadsheets and choose Open to select your workbook.
  2. 2. Enter the dates: Enter the start date in E17 and the end date in F17.
  3. 3. Add the formula: Select a result cell and enter =IF(DATEDIF(E17,F17,"d")+1>30,1,DATEDIF(E17,F17,"d")+1).
  4. 4. Calculate and save: Press Enter to calculate the result, then use File > Save to save the workbook.
Apply the same IF and DATEDIF date-range formula.Open and edit Microsoft Excel XLSX and XLS files.Work with a familiar spreadsheet interface.Use WPS Office for free.
microsoft office alternative - wps office

Frequently Asked Questions

Why does March 31 through April 30 sometimes return 30 days?

DATEDIF(E17,F17,"d") counts elapsed days and does not include the start date. Add 1 to count both dates, giving 31 days for this range.

Does this formula calculate actual calendar months?

No. The formula returns 1 whenever the day count exceeds 30; it does not measure calendar months and also returns 1 for longer ranges.

What if the end date is earlier than the start date?

DATEDIF returns a #NUM! error. Check E17 and F17 and make sure the start date is on or before the end date.

How can I tell whether a result of 1 means one day or one month?

The numeric formula returns 1 in both cases. Use a separate label or modify the formula to return text such as "1 month" for ranges over 30 days.