I am trying to transform a date column to week by using the following code:
select trunc(join_date, 'D') as join_wk from my_table
But I got the following errors:
function trunc(timestamp without time zone, "unknown") does not exist
Hint: No function matches the given name and argument types. You may need to add explicit type casts.
where join_date
is of the format:
2017-08-24 14:49:59
What did I do wrong in the query? Thanks!
The name of the function is date_trunc
, you have to swap the parameters:
SELECT DATE_TRUNC('D', join_date) AS join_wk FROM my_table