Google-sheets – Cell Reference in a QUERY statement not working

google sheetsgoogle-sheets-query

I'm trying to add a cell reference (on the same sheet where the QUERY function is at) to a QUERY function

On B1 there is this value: 13/09/2019

QUERY function:

=QUERY(FORMULARIO!A1:S, "SELECT G WHERE Q contains '13/09/2019'")

I tried doing this but didnt work:

=QUERY(FORMULARIO!A1:S, "SELECT G WHERE Q contains '"&B2&"'")

I cant use a FILTER function here because I'm grabbing selected columns from the master sheet and changing the original order and FILTER doesn't allow that

What am I doing wrong?

Best Answer

When dealing with dates in Google Sheets Query function, dates should be in a certain format.
They need to be as a string literal in the format yyyy-mm-dd, otherwise it can’t perform the comparison filter.

Query function needs dates in yyyy-mm-dd format

In your case your formula should read 2019-09-13
=QUERY(FORMULARIO!A1:S, "SELECT G WHERE Q contains '2019-09-13'")