Question

DATE_TRUNC timestamp to week in SQL Runner

  • 28 September 2021
  • 2 replies
  • 55 views

Hello, I’m using SQL Runner for the first time and am attempting to roll up a series of dates into their respective report weeks. 
I’ve attempted using DATE_TRUNC(‘week’, column_name) but it won’t run in SQL Runner. I’ve tried looking up other work-arounds for Looker’s SQL Runner specifically and am at a loss. Any ideas? Thanks in advance!


2 replies

Userlevel 1

Hiya!

In SQL Runner we need to use the syntax required by your database dialect, not really specific to Looker SQL Runner.

And the query you write there will run directly on the database.

So, when you say “it won’t run” - what’s the error returned? What would be the syntax for this function in your dialect? 

If your query can run smoothly on the DB server, then it should work fine in Looker. 
for DATE_TRUNC , some DBs have that like : DATE_TRUNC( column_name, ‘week’)  as weekID

also you have to GROUP BY this field (weekID)

Reply