How can I use the QUERY function in Google Sheets to filter data by month? 2

How can I use the QUERY function in Google Sheets to filter data by month?

The QUERY function in Google Sheets is a powerful tool that allows users to filter and sort data in a spreadsheet by specific criteria. This function is particularly useful for organizing and analyzing data by month. By using the QUERY function, users can specify a certain month or range of months to filter their data and only display the relevant information. This can be done by using the “where” clause in the function and specifying the column that contains the dates. By utilizing the QUERY function, users can efficiently organize their data and extract valuable insights based on specific time periods.

Google Sheets: 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:

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:

Cite this article

stats writer (2024). How can I use the QUERY function in Google Sheets to filter data by month?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-i-use-the-query-function-in-google-sheets-to-filter-data-by-month/

stats writer. "How can I use the QUERY function in Google Sheets to filter data by month?." PSYCHOLOGICAL SCALES, 30 Jun. 2024, https://scales.arabpsychology.com/stats/how-can-i-use-the-query-function-in-google-sheets-to-filter-data-by-month/.

stats writer. "How can I use the QUERY function in Google Sheets to filter data by month?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-i-use-the-query-function-in-google-sheets-to-filter-data-by-month/.

stats writer (2024) 'How can I use the QUERY function in Google Sheets to filter data by month?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-i-use-the-query-function-in-google-sheets-to-filter-data-by-month/.

[1] stats writer, "How can I use the QUERY function in Google Sheets to filter data by month?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.

stats writer. How can I use the QUERY function in Google Sheets to filter data by month?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.

Download Post (.PDF)
Slide Up
x
PDF
Scroll to Top