22.9 C
London
Sunday, June 22, 2025
HomeSoftware TutorialsGoogle SheetsHow to Use TODAY() Function in Google Sheets Query

How to Use TODAY() Function in Google Sheets Query

Related stories

Learn About Opening an Automobile Repair Shop in India

Starting a car repair shop is quite a good...

Unlocking the Power: Embracing the Benefits of Tax-Free Investing

  Unlocking the Power: Embracing the Benefits of Tax-Free Investing For...

Income Splitting in Canada for 2023

  Income Splitting in Canada for 2023 The federal government’s expanded...

Can I Deduct Home Office Expenses on my Tax Return 2023?

Can I Deduct Home Office Expenses on my Tax...

Canadian Tax – Personal Tax Deadline 2022

  Canadian Tax – Personal Tax Deadline 2022 Resources and Tools...

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:

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.

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

Subscribe

- Never miss a story with notifications

- Gain full access to our premium content

- Browse free from up to 5 devices at once

Latest stories