0

I am trying to query a google sheet by date. I have done some research and learned I need to convert to TEXT format so that I can run the comparison, but I am not able to get the syntax correctly:

=query('SheetName'!$A2:$S, "select A Where O=date'"&TEXT(B2,"yyyy-mm-dd")&)

Could you give me some guidance?

Some more info: in my query, B2 is a valid date in date format. Column O has some cells that are text strings and others that are valid dates; I have set the format of the entire column to "Date".

Here is a link to a simple example, feel free to play around with the query: https://docs.google.com/spreadsheets/d/1O4ms9ufvZ_CRLl_LG45hksjRoOJtv0XexbfjCLqFW4I/edit?usp=sharing

2 Answers 2

0

See if this works?

=filter('SheetName'!A3:A, 'SheetName'!O3:O=B2)
0

correct syntax should be:

=ARRAYFORMULA(QUERY(TO_TEXT(SheetName!$A2:$S),
 "select Col16 where Col15 = '"&TO_TEXT(DATEVALUE(B2))&"'"))

0

6
  • thank you. the query is OK now (no error), but it only returns column headers, not content. I am sure it should be returning a bunch of records. Apr 24, 2019 at 2:50
  • are those records valid numbers only? if so then try: =ARRAYFORMULA(QUERY(TO_TEXT('SheetName'!$A2:$S), "select Col1 where Col15 = date '"&TEXT(B2, "yyyy-mm-dd")&"'", 0))
    – player0
    Apr 24, 2019 at 2:54
  • or perhaps: =ARRAYFORMULA(QUERY({TO_TEXT('SheetName'!$A2:$A),'SheetName'!$B2:$S}, "select Col1 where Col15 = date '"&TEXT(B2, "yyyy-mm-dd")&"'", 0))
    – player0
    Apr 24, 2019 at 2:57
  • Thanks, but no luck with those. Some more info: in my query, B2 is a valid date in date format. Column O has some cells that are text strings and others that are valid dates. I have set the format of the entire column to "date". Apr 24, 2019 at 3:03
  • I added a URL with a small sample that allows you to play around with it. Apr 24, 2019 at 3:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.