Search code examples
google-sheets

QUERY command WHERE parameter not finding match - format error?


The following command, =QUERY(J6:O, "Select J,K,L,M,N,O WHERE J= ' " &A2& " ' AND L>= date ' " & text(B2,"yyyy-mm-dd") & " ' AND L<= date ' " & text(C2,"yyyy-mm-dd") & " ' ") J= not matching values to A2, but when I hard code it into command then it work. J=211081 is working. Link to Sheet: https://docs.google.com/spreadsheets/d/1G2Hyo3z1xGZ91_838-mLdiP7Tmf0lKEnDJTLtTNreiE/edit?usp=sharing Purpose: Select J=A2 and L>=B2 and L<=C2


Solution

  • Remove single quotes
    From ' " &A2& " ' to " &A2& "

    =QUERY(J7:O, "Select J,K,L,M,N,O WHERE J="& $A$2&" AND L>= date '" & text(B2,"yyyy-mm-dd") & "' AND L<= date '" & text(C2,"yyyy-mm-dd") & "'  ")
    

    enter image description here