0
votes

I have a problem with my google sheet query.

=query(teachers,"select A,B,C,D,E,F where B = '"&A2&"' AND G = date '"&TEXT(DATEVALUE("'"&B2&"'"),"yyyy-mm-dd")&"' label A 'DATE', B 'NAME OF TEACHER', C 'LOG IN FOR', D 'LOG IN TIME', E 'LOG OUT FOR', F 'LOG OUT TIME'",1)

WHERE cell B2 is a dropdown filter (using data range) where user will select the date he/she wants to display dynamically. But it resulted to an error says "cannot be parsed to date/time". But if i change the value like this:

=query(teachers,"select A,B,C,D,E,F where B = '"&A2&"' AND G = date '"&TEXT(DATEVALUE("6/2/2020"),"yyyy-mm-dd")&"' label A 'DATE', B 'NAME OF TEACHER', C 'LOG IN FOR', D 'LOG IN TIME', E 'LOG OUT FOR', F 'LOG OUT TIME'",1)

it will work but I want that cell B2 to be controlled dynamically by the user.

Please help me with my problem. Thanks!

1

1 Answers

0
votes

I'd say you just need to remove the quotes around B2:

TEXT(DATEVALUE(B2),"yyyy-mm-dd")

Reference: