Help please: Google Sheets QUERY with DATE and SORT BY

31 views
Skip to first unread message

Josh

unread,
May 8, 2019, 7:56:58 AM5/8/19
to Google Apps Script Community
Sorry I'm just new to QUERY command and haven't been able to find a lot of how's and whys.

I have a sheet with data in it, this code pulls out what I want, stuff that matches today's date. Working fine.

=QUERY(Sheet1!$A2:$N14,"select C,B,D,I,J,K,L where A = date '"&TEXT(TODAY(),"yyyy-MM-dd")&"'")

I wish to then "order by H desc" but I don't know where or how to add that and get a result that's not an error.

I also haven't found what &"'" does or why it makes the date part work, but it does.
Please enlighten me!
Thanks
Josh

Reno Blair

unread,
May 8, 2019, 12:36:47 PM5/8/19
to google-apps-sc...@googlegroups.com
I believe your formula should be
=QUERY(Sheet1!$A2:$N14,"select C,B,D,I,J,K,L where A = date '"&TEXT(TODAY(),"yyyy-MM-dd")&"' order by H desc")

The "'" is closing the string started after date within the query string, encapsulating the result of TEXT(TODAY()...).

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-script-community.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/df1217e1-2bba-4d63-91a3-27bf01ce8e95%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Reno Blair
Educational Technology Services​

Josh MacClure

unread,
May 8, 2019, 5:16:57 PM5/8/19
to Google Apps Script Community
Perfect thank you!
Ahh yes I see that now, thank you again
:)


On Thursday, May 9, 2019 at 4:36:47 AM UTC+12, Reno Blair wrote:
I believe your formula should be
=QUERY(Sheet1!$A2:$N14,"select C,B,D,I,J,K,L where A = date '"&TEXT(TODAY(),"yyyy-MM-dd")&"' order by H desc")

The "'" is closing the string started after date within the query string, encapsulating the result of TEXT(TODAY()...).

On Wed, May 8, 2019 at 4:57 AM Josh <joshi...@gmail.com> wrote:
Sorry I'm just new to QUERY command and haven't been able to find a lot of how's and whys.

I have a sheet with data in it, this code pulls out what I want, stuff that matches today's date. Working fine.

=QUERY(Sheet1!$A2:$N14,"select C,B,D,I,J,K,L where A = date '"&TEXT(TODAY(),"yyyy-MM-dd")&"'")

I wish to then "order by H desc" but I don't know where or how to add that and get a result that's not an error.

I also haven't found what &"'" does or why it makes the date part work, but it does.
Please enlighten me!
Thanks
Josh

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages