gpt4 book ai didi

database - 递增/递减时序

转载 作者:行者123 更新时间:2023-11-29 14:36:26 29 4
gpt4 key购买 nike

我需要增加/减少 PostgreSQL 数据库中的计时。

下面是包含列类型为"timestamp without time zone"

的表的输出

如果时间超过 24 小时,我也需要更改日期。请协助

select start_time from XXXXX;

"2017-05-15 15:08:54.639"
"2017-05-10 17:30:25.056"
"2017-05-10 17:35:35.418"
"2017-05-11 15:05:40.071"
"2017-05-11 18:11:51.431"
"2017-05-18 11:15:00"
"2017-05-11 15:07:43.534"
"2017-05-11 15:10:15.808"
"2017-05-11 15:15:24.847"
"2017-05-15 17:39:00"

如果我增加 1 小时,示例输出应如下所示

   "2017-05-15 16:08:54.639"
"2017-05-10 18:30:25.056"
"2017-05-10 18:35:35.418"
"2017-05-11 16:05:40.071"
"2017-05-11 19:11:51.431"
"2017-05-18 12:15:00"
"2017-05-11 16:07:43.534"
"2017-05-11 16:10:15.808"
"2017-05-11 16:15:24.847"
"2017-05-15 18:39:00"

最佳答案

只需添加一个 interval of 1 hour到值:

select start_time + interval '1' hour
from ...

关于database - 递增/递减时序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43972652/

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