Summary

To filter data to include records between two dates, you can use the FILTER function with boolean logic. In the example shown, the formula in F8 is:

=FILTER(B5:D15,(C5:C15>=F5)*(C5:C15<=G5),"No data")

Which returns records with dates between January 15 and March 15, inclusive.

Generic formula

=FILTER(data,(dates>=A1)*(dates<=A2),"No data")

Explanation 

This formula relies on the FILTER function to retrieve data based on a logical test created with a boolean logic expression. The array argument is provided as B5:D15, which contains the full set of data without headers. The include argument is based on two logical comparisons:

(C5:C15>=F5)*(C5:C15<=G5)

The expression on the left checks if dates are greater than or equal to the "From" date in F5. This is an example of boolean logic. The expression on the right checks if dates are less than or equal to the "To" date in G5. The two expressions are joined with a multiplication operator, which creates an AND relationship.

After logical expressions are evaluated, we have:

({TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE})*
({TRUE;TRUE;TRUE;TRUE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE})

Note there are eleven results in each set of parentheses, one for each date in the data. The multiplication operation coerces the TRUE FALSE values to 1s and 0s, so the final result is a single array like this:

{1;1;1;1;0;0;0;0;0;0;0}

Note the four 1s in the array correspond to the four dates that pass the test. This array is delivered to the FILTER function and used to filter the data. Only rows where the result is 1 make it into the final output.

The if_empty argument is set to "No data" in case no matching data is found.

Dynamic Array Formulas are available in Office 365 only.
Dave Bruns Profile Picture

AuthorMicrosoft Most Valuable Professional Award

Dave Bruns

Hi - I'm Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.