Mavis
Mavis

Reputation: 19

Query function behaving strange with dates in google sheets

Function which isn't working: =QUERY(A:B, "SELECT A WHERE B > " & D1, 0)

What it's looking at:

A B
Strings 13 Feb 2023
Strings 18 Feb 2023
Strings 21 Feb 2023

Cell D1 = 10 Feb 2023

Trouble shooting: The query is coming up no results. All dates are numbers, when I format them as numbers instead of dates it works, when I format them as DD MMM, it works, but when I format them as DD MMM YYYY it doesn't work and this is the format I need it in.

Question Why is Query so sensitive to date formats?? I always use different date formats depending on the sheet and vlookup has no issue with this. Also why on earth would it just not accept one format? I really want to learn for future

Upvotes: 1

Views: 32

Answers (1)

rockinfreakshow
rockinfreakshow

Reputation: 30240

for query you may use:

=QUERY(A:B, "SELECT A WHERE B > date'"&text(D1,"yyyy-mm-dd")&"'")

enter image description here

if you wish to avoid the query confusion; you may just go with simple filter Fx

=filter(A:A,B:B>D1)

enter image description here

Upvotes: 1

Related Questions