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 &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 &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 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.
We can use the following formula to retrieve the rows where the value in the Date column is equal to or after 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:
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.
Additional Resources
The following tutorials explain how to perform other common operations in Google Sheets:
Google Sheets Query: How to Filter by Date Range
Google Sheets Query: How to Use Multiple Criteria in Query
Google Sheets Query: How to Use Cell Reference in Formula