How to Calculate the Number of Days in July Between Two Dates in Excel
Question details
The user needs an Excel formula to count the exact number of days in July that fall within a given date range.
- Product
- Excel
- Device & OS
- not provided
- Scenario
- Tracking or reporting on metrics that require isolating the number of days specifically falling in the month of July between a start and end date.
- Observed behavior
- The formula must include the relevant endpoints and return zero when the specified date range does not overlap with July.
Ensure that your start and end dates are formatted as valid Excel dates, not as text, to avoid calculation errors and zero values.
Use the MAX and MIN Formula for Specific Month Calculation
This robust formula isolates the days in July between two dates and correctly returns zero if there is no overlap.
This formula works by finding the overlapping period between your specific date range and the absolute start and end dates of July for the given year.
Place your start date in cell O2 and your end date in cell P2.
In an empty cell where you want the result, enter the formula: =MAX(0,MIN(P2,DATE(YEAR(P2),7,31))-MAX(O2,DATE(YEAR(O2),7,1))+1)
Press the Enter key to execute the formula. It will return the number of days that fall in July.
Alternative Same-Month Calculation Formula
Use this simplified alternative if you are working strictly within the same month, though it is less versatile for cross-year ranges.
Calculate Dates Easily with WPS Spreadsheet
WPS Spreadsheet fully supports advanced date and time functions, allowing you to calculate overlapping days, manage schedules, and process data effortlessly.
- 1. Open your dataset: Launch WPS Spreadsheet and open your document containing the start and end dates.
- 2. Select a target cell: Click on the blank cell where you want the July days calculation result to appear.
- 3. Input the date formula: Type the formula =MAX(0,MIN(P2,DATE(YEAR(P2),7,31))-MAX(O2,DATE(YEAR(O2),7,1))+1) into the formula bar.
- 4. Execute and fill: Press Enter to get the result, then click and drag the fill handle down to apply the calculation across other date ranges.

Frequently Asked Questions
Why does the formula return an error or zero when there is an overlap?
This usually happens when the dates in your cells are stored as text strings instead of valid Excel dates. You can fix this by selecting the cells, right-clicking to choose 'Format Cells', and applying the 'Date' format.
Can I adapt this formula to calculate days for a different month?
Yes. To calculate days for another month, change the month argument (currently '7' for July) and the end-of-month day (currently '31') in the DATE functions within the formula to match your desired month.
Does the formula include the start and end dates in the count?
Yes, the addition of '+1' at the end of the MIN and MAX equation ensures that the calculation is inclusive of both the start and end endpoints if they fall within July.




