1

I have a spread sheet in google sheets where 'column A' has a date in this format: 20181130.

i am looking to do a query for:

=query(Table1, "select A, B, C, WHERE A = Today(),-1)

But the formats for the today function don't match the column A format, so criteria doesn't find any matches. any help would be appreciated!

CB

Carlo B.
  • 119
  • 2
  • 16
  • ok getting closer, looks like now it says: Error Query completed with an empty output. I should have mentioned the "date" in A1, 20181130 is actually the output of the a formula, =MID(Z1,20,8) ...not sure if that affects the query you provided or not – Carlo B. Nov 30 '18 at 15:55
  • thanks guys, combining both your statements seems to have solved the problem! – Carlo B. Dec 03 '18 at 15:37

2 Answers2

1

Try this one:

=query(Table1, "select A, B, C, WHERE A = date'"&text(Today(),"YYYY-MM-dd")&"'")
Adam K.
  • 26
  • 4
  • This suggestion is valid. Good to know how to automatically generate date using `Today()` in the Query syntax. – Carl H Nov 29 '21 at 17:58
0

According to a Comment, your issue is essentially (other than syntax, which Adam K. seems to have corrected) of trying to compare a Text string to a Date. You might want to change the A1 formula, say to:

 =date(MID(Z1,20,4),MID(Z1,24,2),MID(Z1,26,2))
pnuts
  • 58,317
  • 11
  • 87
  • 139