Search code examples
google-sheetsgoogle-calendar-apigoogle-sheets-formulagoogle-sheets-querygoogle-query-language

Moving Calendar Events around Google Sheets


I have a series of Google Calendars I am subscribed to. In my main Spreadsheet that I do most of my work out of, I have a launch page that I want to have the events pulled for today and tomorrow from each Calendar.

The data is pulled from Google Calendar and put into a hidden sheet called Under The Hood. I then use the following query to try and pull the ones that are A) relevant and B) Happening today (or tomorrow, two different queries).

Today's Events

=QUERY('Under The Hood'!M4:O13, "select M, N where M contains 'P/U' or M contains 'D/O' and toDate(O) contains 'toDate(TODAY())'",0)

Tomorrow's Events

=QUERY('Under The Hood'!M4:O13, "select M, N where M contains 'P/U' or M contains 'D/O' and O contains date'" & TEXT(TODAY()+1,"yyyy-mm-dd")&"'",0)

Both of these queries give me the same partial list of the events from tomorrow and the day after tomorrow.


Solution

  • your formula should be:

    =QUERY('Under The Hood'!M4:O, 
     "select M,N 
      where M matches '.*P/U.*|.*D/O.*' 
        and O contains date '"&TEXT(TODAY()+1, "yyyy-mm-dd")&"'", 0)
    

    enter image description here