Table of Contents
The TODAY() function in Google Sheets is a powerful tool that allows users to easily retrieve the current date in their spreadsheet. This function can be used in conjunction with the QUERY function to filter and manipulate data based on the current date. By including the TODAY() function in a QUERY formula, users can automatically update their data analysis to reflect the current date, without the need for manual input. This makes it a valuable tool for tracking time-sensitive data and creating dynamic reports. To use the TODAY() function in a QUERY, simply include it as a condition in the query criteria, followed by the desired date format. This function can save time and increase efficiency in data analysis tasks.
Use TODAY() Function in Google Sheets Query
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:

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.
Additional Resources
Cite this article
stats writer (2024). How can I use the TODAY() function in a Google Sheets Query?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-i-use-the-today-function-in-a-google-sheets-query/
stats writer. "How can I use the TODAY() function in a Google Sheets Query?." PSYCHOLOGICAL SCALES, 1 Jul. 2024, https://scales.arabpsychology.com/stats/how-can-i-use-the-today-function-in-a-google-sheets-query/.
stats writer. "How can I use the TODAY() function in a Google Sheets Query?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-i-use-the-today-function-in-a-google-sheets-query/.
stats writer (2024) 'How can I use the TODAY() function in a Google Sheets Query?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-i-use-the-today-function-in-a-google-sheets-query/.
[1] stats writer, "How can I use the TODAY() function in a Google Sheets Query?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, July, 2024.
stats writer. How can I use the TODAY() function in a Google Sheets Query?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.

Comments are closed.