How to use Query in Google Sheets using a month number?

To use Query in Google Sheets using a month number, you can use the MONTH() function. This will return the month number of a given date or a timestamp. You can then use this value in a Query statement to filter out the data you want to display. For example, you can use the statement =QUERY(A2:B16, “SELECT * WHERE MONTH(A2) = 1”) to filter out all the data from the column A with the month number of 1.


You can use the following formula to query for rows in Google Sheets that contain a specific month in a date column:

=QUERY(A1:C13, "select A,B,C where month(A)+1=2", 1) 

This particular query returns the values in columns A, B, and C in the range A1:C13 where the date in column A is equal to 2.

Note that 2 represents the month number, i.e. February. 

To query for rows where the date contains January, use 1. For December, use 12. And so on.

The following examples show how to use this formula in practice.

Example 1: Query Where Date Contains Specific Month

We can use the following query to return all rows where the month in column A contains February:

=QUERY(A1:C13, "select A,B,C where month(A)+1=2", 1) 

The following screenshot shows how to use this query in practice:

Google sheets query month

Notice that the four rows returned by the query all contain February in column A.

Example 2: Query Where Date Contains One of Several Specific Months

We can use the following query to return all rows where the month in column A contains February or April:

=QUERY(A1:C13, "select A,B,C where month(A)+1=2 or month(A)+1=4", 1) 

The following screenshot shows how to use this query in practice:

Note: If you receive any errors when using this formula, make sure that the values in column A are formatted as Dates.

To convert the values in column A to a Date format, simply highlight column A and then click Format along the top ribbon, then click Number, then click Date.

x