Use parameter to choose date part in date_trunc

Hey everyone,

I want to use date_trunc and can choose date part in date_trunc so my user can choose to view the data daily, weekly or monthly.

Here is my query :
SELECT date_trunc(date(order_date),{{timeframe}}) AS date_order from dwh_a

it always get error "A valid date part name is required"

Note : i use bigquery

Hi @diospada
You're looking for this: - upvote by clicking :+1: on the first post
Don't think there's an simple workarounds for BigQuery, but look in the comments.