SQL:函数trunc(没有时区的时间戳,“未知”)不存在

问题描述 投票:0回答:1

我正在尝试使用以下代码将日期列转换为周:

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

我在查询中做错了什么?谢谢!

sql postgresql timestamp-with-timezone
1个回答
3
投票

函数名称是

date_trunc
,你必须交换参数:

SELECT DATE_TRUNC('D', join_date) AS join_wk FROM my_table
© www.soinside.com 2019 - 2024. All rights reserved.