Google-sheets – Query(Importrange) or Query with dates

formulasgoogle sheetsgoogle-sheets-datesgoogle-sheets-queryimportrange

I am trying to show or limit what is seen to just entries made in 2019. I found a few places that referenced this and have tried the following without success.

=query(IMPORTRANGE("1bSyor-91_py58oDPVfalwcSB7Fw4mmJmD1jEOTIE7FU", "FVA_2017!A:M"),"select A,B,C,D,E,F,G,H,I,J,K,L,M where L > date '2019-01-01' and L < date '2019-12-30'")

Or to query the sheet directly from within the same file.

=query("FVA_2017!A:M","select A,B,C,D,E,F,G,H,I,J,K,L,M where L > date '2019-01-01' and L < date '2019-12-30'")

I am getting the same error

"Unable to parse the query string for Function Query parameter 2: NO_COLUMN: A"

trying both of the queries.

If I just do a regular importrange such as

=IMPORTRANGE("1bSyor-91_py58oDPVfalwcSB7Fw4mmJmD1jEOTIE7FU", "FVA_2017!A:M")

I get everything. The date column is L and the format a standard date field from a Google form 4/29/2019. The first row is a header row would this cause an error?

Best Answer

correct syntax:

=QUERY(IMPORTRANGE("1bSyor-91_py58oDPVfalwcSB7Fw4mmJmD1jEOTIE7FU", "FVA_2017!A:M"),
 "where Col12 > date '2019-01-01' 
    and Col12 < date '2019-12-30'", 0)

=QUERY(FVA_2017!A:M, "where L > date '2019-01-01' 
                        and L < date '2019-12-30'", 0)

=QUERY({FVA_2017!A:M}, "where Col12 > date '2019-01-01' 
                          and Col12 < date '2019-12-30'", 0)

=QUERY(INDIRECT("FVA_2017!A:M"), "where Col12 > date '2019-01-01' 
                                    and Col12 < date '2019-12-30'", 0)