Counting the Number of Days Between Two Dates in Excel
To count the number of days between two dates in Excel, you can use either the COUNTIFS or SUMPRODUCT function. The COUNTIFS function counts the number of cells in a range that meet multiple criteria, while SUMPRODUCT multiplies arrays and returns their sum. Both functions require a date range with a lower and upper date specified.
Using COUNTIFS to Count the Number of Days Between Two Dates
To use the COUNTIFS function to count the number of days between two dates, follow these steps:
1. Enter the COUNTIFS function in a cell.
2. In the criteria_range1 argument, refer to the range where you have dates.
3. In the criteria1 argument, enter the greater than (>) and equal sign (=) and enclose between double quotation marks. Then, refer to the cell where you have the lower date.
4. In the criteria_range2 argument, refer to the date range again.
5. In the criteria2 argument, enter the lower than (<) and equal sign (=) and enclose it between double quotation marks. Then, refer to the cell where you have the upper date.
6. Close the function and press Enter to get the result.The formula to count the number of days between two dates using COUNTIFS is:
=COUNTIFS(A2:A17,”>=”&E2,A2:A17,”<=”&F2)
To understand this formula, you can break it down into two parts. In the first part, the condition checks for cells greater than and equal to the date in cell E2. In the second part, the condition checks for cells lower than and equal to the date in cell F2. The resulting count represents the number of days between the two dates.Note that you should enter the greater than (>), lower than (<), and equal (=) operators as text and surrounded by double quotation marks.
Using SUMPRODUCT to Count the Number of Days Between Two Dates
To use the SUMPRODUCT function to count the number of days between two dates, follow these steps:
1. Enter the SUMPRODUCT function in a cell.
2. In the first part of the formula, enter a condition to check all the dates from the range, checking which is lower and equal to the specified date.
3. Use double minus signs to convert TRUE and FALSE values into 1s and 0s.4. In the second part of the formula, again use a condition to test for the cells that meet the criteria.5. Use double minus signs to convert TRUE and FALSE values into 1s and 0s.
6. The resulting arrays are multiplied together and summed to give the count of dates between the range.
The formula to count the number of days between two dates using SUMPRODUCT is:
=SUMPRODUCT(–(A2:A17<=F2),–(A2:A17>=E2))By breaking down this formula, you can see that the first part checks which cells are less than or equal to the specified upper date. The second part checks which cells are greater than or equal to the specified lower date. The resulting arrays are multiplied together, and the sum of their values represents the number of days between the two dates.