PostgreSQL更新时区偏移 [英] PostgreSQL update time zone offset
本文介绍了PostgreSQL更新时区偏移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么是纠正时区的快速简便方法?时区错误的时间戳
字段在错误的时区中意外输入了?
What's a quick and easy way to correct the time zone TIMESTAMP WITH TIME ZONE
fields accidentally entered in the wrong time zone?
在我的情况下,以下记录被错误地输入到UTC而非美国/太平洋地区:
In my case, the following records were mistakenly input in UTC rather than in US/Pacific:
t0 | t1 | what
------------------------+------------------------+---------------
2011-06-01 13:00:00+00 | 2011-06-01 13:10:00+00 | recalibrating
2011-06-01 13:10:00+00 | 2011-06-01 13:45:00+00 | verifying
2011-06-01 13:45:00+00 | 2011-06-01 13:55:00+00 | FAULT
幸运的是,没有任何错误的记录跨越夏令时的界限,因此UTC 2点可以
Fortunately, none of the mistaken records cross daylight savings boundaries, so 2 o'clock UTC can simply be corrected as 2 o'clock Pacific.
推荐答案
UPDATE <table> SET <timestamptz_field> = (<timestamptz_field> AT TIME ZONE 'UTC') AT TIME ZONE '<correct_time_zone>';
这篇关于PostgreSQL更新时区偏移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文