How to Query Using Month using Query function

To query data using the month in the Query function in Google Sheets, you need to use the month() function within the Query function. The month() function extracts the month number from a date. Here's how you can do that:

  1. Assuming you have a range of data with a date column (e.g., A1:E100 with the date in column A).
  2. Choose a cell where you want to display the result of the query.
  3. Use the QUERY() function in the following format:
=QUERY(range, "SELECT * WHERE month(date_column) + 1 = target_month")

Here's an example of how to use the Query function to filter data by month:

Example

Suppose we have the following data:

Date Product Sales
2021-01-01 A 100
2021-01-02 B 200
2021-02-01 A 150
2021-02-02 B 250
2021-03-01 A 300
2021-03-02 B 350

The data range is A1:C6, and we want to display the rows with sales data for February.

  1. Choose a cell where you want to display the result (e.g., E1).
  2. Enter the following formula:
=QUERY(A1:C6, "SELECT * WHERE month(Col1) + 1 = 2")
  1. Press Enter, and the result will be:
Date Product Sales
2021-02-01 A 150
2021-02-02 B 250

The query function returns the rows with sales data for February. Note that we added 1 to the month function because it returns months in the range of 0-11, not 1-12.

Did you find this useful?