sql - 错误 : function date_trunc(timestamp without time zone) does not exist

标签 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)...

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

最佳答案

尝试:

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

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

详情 here .

关于sql - 错误 : function date_trunc(timestamp without time zone) does not exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14340999/

相关文章:

php - mysql问题与添加列

sql - 使用动态 SQL 循环遍历列名

mysql - 如何从一张表中选择用户尚未选择的所有记录?

PHP/MySQL 日期/时间差异

Java 8 : Calculate difference between two ZonedDateTime

sql - 在 SQL 中对 DATEDIFF 函数的结果进行分组

sql - 如何使用 SQL*Plus 从 Oracle 复制到 Sybase?

postgresql - 优化 PostgreSQL 中的查询

python - 如何使用 DjangoORM 在 PostgreSQL 9.6 中使用 StringAgg 聚合函数

python - Pandas 在阅读 csv 时无法识别日期