Search code examples
google-query-language

How to add days to today on a Google Query?


Using Google Query language, how do I properly add days to today?

I tried the below but if fails with an error.

SELECT A, B, C, D, E, F, H, I, K, M, N, R, AF, W WHERE
toDate(A) >= DATE '2021-12-16' and
toDate(A) <= DATE TEXT((TODAY()+15),"yyyy-mm-dd")

Error:

Google Sheets: Invalid query: PARSE_ERROR: Encountered " "toDate" "toDate "" at line 3, column 1. Was expecting: "(" ...

Solution

  • Try

    =query( A:AF ,"SELECT A, B, C, D, E, F, H, I, K, M, N, R, AF, W  WHERE
    TODATE(A) >= DATE'2021-12-16' and
    TODATE(A) <= DATE'"&TEXT((TODAY()+15),"yyyy-MM-dd")&"' ")
    

    enter image description here