How to Use COUNTIF for Date Range in Excel (6 Suitable Approaches)

Here’s an overview of the sample dataset and an example of the COUNTIF function to count data based on multiple criteria. The function is counting the deliveries based on five criteria from the dataset to the right.

countif to count date range in excel overview


Download the Practice Workbook


Introduction to the COUNTIF Function in Excel

  • Objective of the Function:

Counts the number of cells within a range that meets the given condition.

  • Formula Syntax:

=COUNTIF(range, criteria)

  • Arguments:

range- Range of cells that will be subject to the criteria.

criteria- Selected criteria for the range of cells.

  • Example:

In the sample dataset, the columns from B to F represent random names of computer brands, device categories, model names, purchase dates, and delivery dates. We’ll find how many notebooks are in the table.

countif introduction

Steps:

  • Select Cell H15 and insert:
=COUNTIF(C5:C27, "Notebook")
  • Press Enter and you’ll get the result.

countif introduction

In the 1st argument, the Cell Range C5:C27 has been added which represents all device types. We’ve included the criteria by simply typing Notebook within Quotation Marks(“ ”). You can also use a cell reference of a cell that contains Notebook (outside of the main dataset), which allows you to search more dynamically.


6 Suitable Uses of the COUNTIF Function for a Date Range in Excel

Example 1 – COUNTIF to Count Dates Excluding Blank Cells

Steps:

  • Insert the following formula in cell H15, then hit Enter.
=COUNTIF(F5:F27,"<>"&"")

countif to count date range excluding blank cells

In this formula, we are excluding blank cells by typing “<>”&”” in the Criteria argument. By using Ampersand(&), we’re connecting the “Not Equal to” symbol with “Blank Cells”.

Read More: Count Blank Cells with Excel COUNTIF Function: 2 Examples


Example 2 – COUNTIF to Count Dates Before a Fixed Date

We want to find out the number of purchase dates before 5/1/2021.

Steps:

  • Insert the following formula in cell H15, then hit Enter.
=COUNTIF(E5:E27,"<5/1/2021")

countif to count dates older than fixed or particular date

Read More: COUNTIF Date Is within 7 Days


Example 3 – COUNTIF to Count Dates After a Fixed Date

We’ll determine the number of dates newer than 4/30/2021.

Steps:

  • Insert the following formula in cell H15, then hit Enter.
=COUNTIF(E5:E27,">4/30/2021")

countif to count dates newer than fixed or particular date in excel

Read More: COUNTIF Greater Than and Less Than [with Free Template]


Similar Readings


Example 4 – COUNTIF or COUNTIFS to Count Dates Between Two Fixed Dates

We’ll determine the number of total purchases between 4/15/2021 and 5/15/2021.

Steps:

  • Insert the following formula in cell H15, then hit Enter.
=COUNTIF(E5:E27,">4/15/2021")-COUNTIF(E5:E27,">5/15/2021")

countif to count date range between two dates in excel

The COUNTIFS function allows us to add multiple criteria for two different dates.

  • Insert the following formula in cell H15, then hit Enter.
=COUNTIFS(E5:E27,">4/15/2021",E5:E27,"<5/15/2021")

countifs to count date range between two dates in excel

Read More: COUNTIF vs COUNTIFS in Excel (4 Examples)


Example 5 – Combining COUNTIF with the TODAY Function to Count Cells up to the Current Date

We’ll find how many purchases have been completed up to the current date.

Steps:

  • Insert the following formula in cell H15, then hit Enter.
=COUNTIF(E5:E27,"<="&TODAY())

countif to count date range upto current date with today function

Read More: Excel COUNTIFS Not Working (7 Causes with Solutions)


Example 6 – COUNTIFS to Count Dates with Multiple Conditions or Criteria

We’ll return the items that fulfill the following criteria: Omicron brand, notebook device, OMN34 as model name, and date of purchase after 4/1/2021. We’ll also find the number of total deliveries up to the current date for those conditions.

Steps:

  • Insert the following formula in cell I17, then hit Enter.
=COUNTIFS(B5:B27,I12,C5:C27,I13,D5:D27,I14,E5:E27,">4/1/2021",F5:F27,"<="&TODAY())

countif to count date range with multiple criteria or conditions in excel

  • To find any delivery under the given criteria that is still pending, insert the following formula in Cell I18:
=COUNTIFS(B5:B27,I12,C5:C27,I13,D5:D27,I14,E5:E27,">4/1/2021",F5:F27,"Pending")

countif to count date range with multiple criteria or conditions in excel

Read More: How to Use Excel COUNTIF That Does Not Contain Multiple Criteria


Related Articles

Get FREE Advanced Excel Exercises with Solutions!
Nehad Ulfat
Nehad Ulfat

NEHAD ULFAT is an excellent marine engineer who loves working with Excel and diving into VBA programming. For him, programming is like a tool that saves time when dealing with data, files, and the internet. His skills go beyond the basics, including ABACUS, AutoCAD, Rhinoceros, Maxsurf, and Hydromax. He got his B.Sc in Naval Architecture & Marine Engineering from BUET but switched gears, working as a content developer.  In this role, he creates techy content all about Excel... Read Full Bio

4 Comments
  1. Thank you so much! This article was extremely helpful. The sixth section was exactly what I was looking for.

  2. I tried using the formula within a date range and it counts some of the data, but not all. I can manually see there should be 70 and it is only counting 50. I double checked all the data to make sure the dates are listed correctly. Can you help me figure out why It is not counting all the data? Do I need to clear out the dates and reinsert them?

    • Reply Avatar photo
      Osman Goni Ridwan Aug 4, 2022 at 4:20 PM

      Hello SONYA, you can face this issue because of the following reasons:
      1. Incorrect Cell Ranges used in the formula
      2. The Date format used in the formula is not correct. You have to use a similar data format both in the cells and formulas.

      Check these things in your workbook and let us know the outcome. Thanks!

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo