错误:函数date_trunc(没有时区的时间戳)不存在

时间:2013-01-15 15:27:39

标签: sql postgresql datetime

嘿伙计们,我有这个问题。我有一个sql查询我试图对我的postgres数据库。这些查询在oracle中工作正常,但我正在将其转换为postgres查询,但它抱怨。这是查询:

select  to_char(calldate,'Day') as Day, date_trunc(calldate) as transdate,
Onnet' as destination,ceil(sum(callduration::integer/60) )as    total_minutes,round(sum(alltaxcost::integer) ,2)as revenue
from cdr_data 
where callclass ='008' and callsubclass='001'
and callduration::integer >0
and  regexp_like(identifiant,'^73')
and bundleunits = 'Money'
and inserviceresultindicator in (0,5)
and regexp_like(regexp_replace(callednumber,'^256','') ,'^73')
group by  to_char(calldate,'Day') ,trunc(calldate),'Onnet' order by 2

我得到的错误是:

Err] ERROR:  function date_trunc(timestamp without time zone) does not exist
LINE 4: select  to_char(calldate,'Day') as Day, date_trunc(calldate)...

我做错了什么或者这个错误的解决方案是什么。

1 个答案:

答案 0 :(得分:10)

尝试:

... date_trunc('day',calldate) ...

对于PostgreSQL date_trunc()函数,您必须始终将precision指定为第一个参数。

详情here

相关问题