Google Sheets Query with Date and Time

formulasgoogle sheetsgoogle-sheets-arrayformulagoogle-sheets-queryvlookup

I need help with a query. I need to filter on some Google Form data and only show the results that have been submitted AFTER a specific timestamp.

Timestamp Cell = J2 – This cell is in the following format mm/dd/yyyy hh:mm:ss

Day Query – This one seems to work ok but its only at the day level.

=query(FormResponses!A2:G,"Select * Where A > date '"&text(J2,"YYYY-mm-dd") & "'" )

Time of Day Query – This one also seems to work ok but only at the time level.

=query(FormResponses!A2:G,"Select * Where A > timeofday'" & text(J2, "HH:mm:ss") & "'" )

When I try to combine the two, it returns no results and I can not figure out why. I do see some wierd issues with the ">" in the queries above so i am second guessing the accuracy of the above queries to begin with. Does anyone have a sample of checking both date and time in a google sheets query?

Best Answer

=ARRAYFORMULA(VLOOKUP(TO_DATE(QUERY(VALUE(QUERY(FormResponses!A2:A, 
 "select *", 0)), 
 "select Col1 where Col1 > "&VALUE(J2), 0)), 
 {VALUE(FormResponses!A2:A), FormResponses!B2:G}, 
 {1, 2, 3, 4, 5, 6, 7}, 0))