我正在尝试使用以下代码将日期列转换为周:
select trunc(join_date, 'D') as join_wk from my_table
但是我遇到了以下错误:
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.
其中
join_date
的格式为:
2017-08-24 14:49:59
我在查询中做错了什么?谢谢!
函数名称是
date_trunc
,你必须交换参数:
SELECT DATE_TRUNC('D', join_date) AS join_wk FROM my_table