Using the COUNTIF Function to find if a Date Is within 7 Days – 2 Methods

Practice Workbook

Download the following workbook and exercise.


The Excel COUNTIF Function

The COUNTIF function counts the cells in an array or range that match a single criterion.

  • Syntax:

=COUNTIF (range, criteria)

  • Arguments:

range: The cell range to count.

criteria: Single criterion applied to the range.


The Excel COUNTIFS Function

The COUNTIFS function counts the cells in an array or range that match multiple criteria.

  • Syntax:

=COUNTIFS (criteria_range1, criteria1, [criteria_range2, criteria2], ..)

  • Arguments:

criteria_range1: The first cell range to count.

criteria1: Criteria applied to criteria_range1.

  • Optional Arguments:

criteria_range2: The second cell range to count.

criteria2: Criteria applied to criteria_range2.


Method 1 – Counting If the Date is within 7 Days using the Excel COUNTIF Function

This is the sample dataset.

Count If Date is within 7 Days with Excel COUNTIF Function

STEPS:

  • Select E8.
  • Enter the formula:
=COUNTIFS(C5:C11,">"&TODAY()-E5,B5:B11,F5)

Count If Date is within 7 Days with Excel COUNTIF Function

  • Press Enter to see the result.

Formula Breakdown

TODAY()

returns the current date.

TODAY()-E5

subtracts ‘7’ from the current day.

C5:C11,”>”&TODAY()-E5

returns the total number of days greater than or equal to the returned date.

B5:B11,F5

returns the total number of ‘BKD’ items.

COUNTIFS(C5:C11,”>”&TODAY()-E5,B5:B11,F5)

counts the total number of cells.

Read More: Excel COUNTIF with Greater Than and Less Than Criteria


Method 2 Using the Excel COUNTIF Function to Count a Date within 7 Days Excluding Future Dates

Excel COUNTIF Function to Count Date within 7 Days Excluding Future Date

STEPS:

  • Select E7.
  • Enter the formula:
=COUNTIF(C:C,">="&TODAY()-7)-COUNTIF(C:C,">"&TODAY())

  • Press Enter to see the result.

Formula Breakdown

TODAY()

returns the current date.

TODAY()-7

subtracts ‘7’ from the current day.

COUNTIF(C:C,”>=”&TODAY()-7)

returns the total number of days greater than or equal to the returned date.

COUNTIF(C:C,”>”&TODAY())

returns the total number of future dates.

COUNTIF(C:C,”>=”&TODAY()-7)-COUNTIF(C:C,”>”&TODAY())

returns the subtracted value.


Similar Readings


Alternative to the COUNTIF Function to Find If a Date is within 7 Days

Alternative to COUNTIF Function to Counit If Date is within 7 Days

STEPS:

  • Select E8.
  • Enter the formula:
=SUMPRODUCT(--($C$5:$C$11>TODAY()-$E$5),--($B$5:$B$11=$F$5))

Alternative to COUNTIF Function to Counit If Date is within 7 Days

  • Press Enter to see the result.

Formula Breakdown

TODAY()

returns the current date.

TODAY()-$E$5

subtracts ‘7’ from the current day.

 –($C$5:$C$11>TODAY()-$E$5)

is the first array.  ‘’ converts a series of TRUE and FALSE into ‘0’ or ‘1’ in the array. It will return the total number of days greater than the returned date.

 –($B$5:$B$11=$F$5)

is the second array.  ‘’ functions as described above. It returns the total number of ‘CKD’ items.

 SUMPRODUCT(–($C$5:$C$11>TODAY()-$E$5),–($B$5:$B$11=$F$5))

sums the amounts found from the above procedure.

Read More: COUNTIF Between Two Dates in Excel (4 Suitable Examples)


Related Readings

Get FREE Advanced Excel Exercises with Solutions!
Nuraida Kashmin
Nuraida Kashmin

Nuraida Kashmin, Bachelor's degree in Mechanical Engineering from Rajshahi University of Engineering & Technology. Since 2021, she wrote 45+ articles on Excel problems and reviewed over 1000 articles. Currently working as a Project Manager, she is responsible for developing and implementing content strategies, managing writers and editors, staying updated on new technology, analyzing data, and tracking content performance indicators. Her interests include Project Management, Creative Writing, Digital Marketing, Reporting, Monitoring & Documentation, and Online Advocacy for SAP &... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo