Google-sheets – Using QUERY command with dates

google sheetsgoogle-sheets-queryimportrange

I have a column in Sheet1 that contains dates in format DD/MM/YYYY, like this:

12/10/2015
28/09/2015
28/09/2015
28/09/2015
28/09/2015
28/09/2015
28/09/2015
26/10/2015
26/10/2015
26/10/2015
26/10/2015
12/10/2015
12/10/2015
12/10/2015

And I'm trying to select with a QUERY all the entries that are less than 15/10/2015. I know there are other methods but I need to use SQL syntax (this is a simplified version of the big formula and I need SQL to make the other bits work).

=QUERY(IMPORTRANGE("BLABLABLA", "Sheet1!A2:A"),"SELECT * WHERE Col1 <= '15/10/2015'")

But the query completes with an empty response. I even tried to use the MM-DD-YYYY format in the QUERY or just "2016"—still an empty response.

My spreadsheet’s locale is UK.

Best Answer

Replace

WHERE Col1 <= '15/10/2015'

with

WHERE Col1 <= date '2015-10-15'

That is, you need to provide date in ISO format and precede it with the keyword date so that it is parsed accordingly.