Search code examples
google-sheets-formula

Why does this query in Google Sheets, with dates, still return the first row?


In Google Sheets, when I use the following query, with TODAY() being set to the day after tomorrow:

=QUERY(Master!A2:R1000,"select H, K where K > date '"&TEXT(TODAY()+2,"yyyy-mm-dd")&"'",1)

H K
7-14 9/30/2023 10:43 PM
8-16 9/30/2023 10:34 PM

I'm expecting it to return N/A (no results found), but instead, it returns:

7-14 9/30/2023 10:43 PM

Why is this the case? K being later than the day two days from now should be impossible.


Solution

  • Try changing that final "1", and put a "0" instead. You're telling the QUERY that row A2:R2 is the header

    =QUERY(Master!A2:R1000,"select H, K where K > date '"&TEXT(TODAY()+2,"yyyy-mm-dd")&"'",0)