【发布时间】:2012-08-18 14:17:54
【问题描述】:
MySQL 有一个很酷的函数sec_to_time(),它可以将你的秒数转换为 hh:mm:ss
我已经阅读了邮件列表,基本上是在尝试实现以下内容:
MySQL:
select sec_to_time(sum(unix_timestamp(enddate) - unix_timestamp(startdate))) from foo;
PostgreSQL:
select XXX(sum(date_part('epoch',enddate) - date_part('epoch',startdate))) from foo;
我只需要知道 XXX 是/可以是什么。我已经尝试了很多记录功能的组合。
请让我们在 PostgreSQL 中如何做到这一点?
【问题讨论】:
-
它抛出 ERROR: function justify_interval(double precision) does not exist LINE 1: SELECT justify_interval(sum(date_part('epoch',log_reports.lo...
-
to_char也许?传递您的时间戳并指定您要输出的格式。
标签: mysql database postgresql postgresql-9.1 postgresql-9.0