How can I use the TODAY() function in Google Sheets Query?

The TODAY() function in Google Sheets Query can be used to return the current date and time in a cell. This function can be used in combination with other functions such as COUNTIFS, SUMIFS, and AVERAGEIFS to calculate values based on the current date or to filter data by date.


The TODAY() function in Google Sheets can be used to retrieve the current date.

You can use the following basic syntax to perform a query in Google Sheets where some date variable is before the current date:

=QUERY(A1:C9,"select A, B, C where B < date '"&TEXT(TODAY(),"yyyy-mm-dd")&"'", 1)

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

Example 1: Use TODAY() Function to Retrieve Rows Before Current Date

Suppose we have the following dataset that shows the total sales made by two stores on various dates:

Let’s assume the current date is 1/18/2022.

We can use the following formula to retrieve the rows where the value in the Date column is before the current date:

=QUERY(A1:C9,"select A, B, C where B < date '"&TEXT(TODAY(),"yyyy-mm-dd")&"'", 1)

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

Google Sheets Query TODAY function example

Notice that the only rows returned by the query are the ones where the value in the Date column is before the current date.

Example 2: Use TODAY() Function to Retrieve Rows Equal to or After Current Date

Once again suppose we have the following dataset that shows the total sales made by two stores on various dates:

Let’s again assume the current date is 1/18/2022.

=QUERY(A1:C9,"select A, B, C where B >= date '"&TEXT(TODAY(),"yyyy-mm-dd")&"'", 1)

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

Notice that the only rows returned by the query are the ones where the value in the Date column is equal to or after the current date.

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

x