How to Filter by Date Range using Query function

To filter by date range using the Query function in Google Sheets, you'll need to use a combination of the "where" clause and the "date" function. Here's a step-by-step guide on how to do it:

  1. Open your Google Sheets document, and make sure your data has headers, including a date column.
  2. Click on an empty cell where you want the filtered data to appear.
  3. Use the Query function in the following format:
=QUERY(data_range, "select * where date_column >= date 'start_date' and date_column <= date 'end_date'", header_row)

Example

Let's say you have data in the range A1:D10, with headers in the first row, and the date column is in column A. You want to filter the data to show only records between January 1, 2021, and December 31, 2021. To do this, follow these steps:

  1. Click on an empty cell, for example, E1.
  2. Enter the following formula:
=QUERY(A1:D10, "select * where A >= date '2021-01-01' and A <= date '2021-12-31'", 1)
  1. Press Enter. The filtered data will now appear in columns E to H, showing only records between January 1, 2021, and December 31, 2021.
Did you find this useful?