Google Sheets query to select records >= a variable date

Viewed 1732

I'm trying to select records that are >= a calculated field. Here is the query:

=QUERY('Employer Form Responses'!A:Q,"select * where A >='"&B1&"' ",1)

Column A in the data is a Date field (e.g. 9/14/2020 18:46:39) and field B1 contains

=TEXT(DATEVALUE(TODAY()-30),"YYYY-MM-DD")

The query gives me an empty result. How should I do this?

1 Answers

You have to let a query know that you're comparing a date by simply adding date after the comparison operator. Below is that added to the query in your post.

=QUERY('Employer Form Responses'!A:Q,"select * where A >= date '"&B1&"' ",1)

More info on the weirdness between dates and query here: https://www.benlcollins.com/spreadsheets/query-dates/

Related