Google Sheets: How to Query Using Month


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:

Notice that all of the rows returned by the query contain either February or April in column A.

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.

Additional Resources

The following tutorials explain how to perform other common tasks in Google Sheets:

How to Add Months to Date in Google Sheets
How to Group Data by Month in Google Sheets
Convert Between Month Name & Number in Google Sheets

Leave a Reply

Your email address will not be published.