Search code examples
google-sheetsgoogle-sheets-formula

Unable to figure out datetime query in Google Sheet


Hi Im unable to figure out whats wrong with my datetime query =QUERY(A:G,"SELECT * WHERE G < datetime '2022-08-24 08:45:00'",1) in my Google Sheet it should return 2 rows on the left whos datetimes in G are < 2022-08-24 08:45:00 (also supplied screenshot) enter image description here


Solution

  • I have made changes to formula to your G column =DATE(LEFT(B2,4),MID(B2,5,2),RIGHT(B2,2))+(TIME(C2,D2,0)) to make it pure datetime value. Then use below query formula.

    =QUERY(A:G,"SELECT * WHERE G < datetime '2022-08-24 08:45:00'",1)
    

    See your google sheet harun24hr.