gpt4 book ai didi

postgresql - Postgres 时间 00 和 24 小时

转载 作者:行者123 更新时间:2023-12-03 19:10:47 24 4
gpt4 key购买 nike

为什么下面的查询返回 false ?

SELECT ('00:00:00'::TIME) = ('24:00:00'::TIME) AS "time", ('00:00:00'::TIMETZ) = ('24:00:00'::TIMETZ) AS "timetz"

结果:

+-------+--------+
| time | timetz |
+-------+--------+
| false | false |
+-------+--------+


虽然以下查询的结果是一样的!!

SELECT ('00:00:00'::TIME) AS "time1", ('24:00:00'::TIME) AS "time2", ('00:00:00'::TIMETZ) AS "timetz1" , ('24:00:00'::TIMETZ) AS "timetz2"

结果:

+----------+----------+------------------------+------------------------+
| time1 | time2 | timetz1 | timetz2 |
+----------+----------+------------------------+------------------------+
| 00:00:00 | 00:00:00 | 00:00:00.000000 +00:00 | 00:00:00.000000 +00:00 |
+----------+----------+------------------------+------------------------+


00:00:00 和有什么区别和 24:00:00在 postgres 中?

最佳答案

Postgres' time类型定义为范围为 '00:00:00''24:00:00' ,包括两端。要了解两个端点为何不同,请考虑:

SELECT '00:00:00'::time AS start, '24:00:00'::time AS end;

对于最终值,我看到 1.00:00:00 ,与您所看到的相反,表明 24 小时实际上是一天,时、分和秒为零。

关于postgresql - Postgres 时间 00 和 24 小时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62262026/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com