Skip to content

PostgreSQL justify_hours() 函数 ​

PostgreSQL justify_hours() 函数转换时间间隔的表示方法,将超过 24 小时的小时数转为天数。

justify_hours() 语法 ​

这是 PostgreSQL justify_hours() 函数的语法:

sql
justify_hours(value INTERVAL) -> INTERVAL

参数 ​

  • value

    必需的。 要转换的间隔值。

返回值 ​

PostgreSQL justify_hours() 函数转换时间间隔的表示方法,将超过 24 小时的小时数转为天数。

如果给定的间隔值小于 24 天,则不做任何转换。

justify_hours() 示例 ​

下面的示例展示了 justify_hours() 函数的基本用法。

sql
SELECT
    justify_hours(INTERVAL '20 hours') AS "20 hours",
    justify_hours(INTERVAL '60 hours') AS "60 hours";
bash
 20 hours |    60 hours
----------+-----------------
 20:00:00 | 2 days 12:00:00