Hi all :grin:

I have successfully linked my Google Sheet with a query in Redash which shows NPS scores (columns are: scores, user email, submitted at, etc.). I am now using “Query Results” as my data source to pull from my Google Sheets query.

My hope is to GROUP BY month. Normally, I would use a date function to separate the month, e.g. SELECT date_trunc(“month”, table.column) AS month [and then use] GROUP BY month. However, date functions seem to be unavailable when using “Query Results” as your data source to pull from a “Google Sheets” data source. My date column is formatted as such:

Submitted At
2018-04-17 12:44
2018-04-17 12:27
2018-04-17 12:20
2018-04-17 12:18

In my case, does anyone have any workarounds within Redash to GROUP BY month when it’s nested in a timestamp? I am trying to avoid having to add an additional column to truncate the date within the Google Sheet. We use a Postgres database. Thanks!

Still need help?

Query Results does not use PostgreSQL, but SQLite, which is not handy to manipulate dates and does not have a date_trunc() function.

However, one way to achieve what you want is to use the strftime() function, as documented by SQLite.

You could write something like:

    strftime('%Y-%m', date) as month,
from query_42
group by month
1 Like