I am having a few problems with dates and times in Google Sheets. What I have is:
Spreadsheet 1 has a number of sheets one of which is called Sessions
. On that sheet there are a number of columns which show all sorts of data about individual training sessions. I then have a second spreadsheet which is published to a Google site which the users can see. It only has one sheet which is populated by a QUERY + IMPORTRANGE to get the information from the Sessions
tab of the first spreadsheet. The reason I do this is I don't want the users to be able to see all the different sheets in the first spreadsheet nor do I want them to see all the different columns in there either. There is one more reason as well. I want the query to filter the sessions to only show ones that are happening in the future, not ones that have already passed.
The query I have in the second sheet to pull the data is:
=query(importrange("IDofMainSpreadsheet","Sessions!A:I");"select Col1,Col2,Col3,Col6")
Now that works fine. What I want to add is something like:
=query(importrange("IDofMainSpreadsheer","Sessions!A:I");"select Col1,Col2,Col3,Col6 where Col2 >= Now()")
I have tried many different solutions but can't seem to find one that works.
Ok.... Have made some developments. It's not pretty but if I add another sheet and create a cell with the following:
=YEAR(now()) & "-" & DEC2OCT(MONTH(now()), 2) & "-" & DAY(now()) &" " & HOUR(now()) &":"& MINUTE(now()) &":"& SECOND(now())
then I can use this in the query:
=query(importrange("IDofSpreadsheet","Sessions!A:I");"select Col1,Col2,Col3,Col6 where Col2 >= datetime '"&Sheet3!B3&"' ")
Would be great if someone could help me do this in a single line. Have tried the toDate(Now())
option as suggested below but this does not return any results whereas the above does.
Any thoughts?