在postgresql中将时间戳转换为间隔
我正在尝试将时间戳转换为interval&期望仅为out of hh:mm 我的代码如下在postgresql中将时间戳转换为间隔,postgresql,Postgresql,我正在尝试将时间戳转换为interval&期望仅为out of hh:mm 我的代码如下 SELECT to_timestamp('2020-01-10 08:00', 'YYYY-MM-DD hh24:mi')::timestamp without time zone at time zone 'Asia/Calcutta' at time zone 'Etc/UTC' 代码的实际用途是将给定日期时间值的时区更改为utc。似乎您正在尝试获取特定时间两个时
SELECT to_timestamp('2020-01-10 08:00', 'YYYY-MM-DD hh24:mi')::timestamp without time zone
at time zone 'Asia/Calcutta'
at time zone 'Etc/UTC'
代码的实际用途是将给定日期时间值的时区更改为utc。似乎您正在尝试获取特定时间两个时区之间的时差(间隔)。
可以这样做,例如:
SELECT to_timestamp('2020-01-10 08:00', 'YYYY-MM-DD hh24:mi')::timestamp without time zone
at time zone 'Asia/Calcutta'
-
to_timestamp('2020-01-10 08:00', 'YYYY-MM-DD hh24:mi')::timestamp without time zone
at time zone 'Etc/UTC'
这将返回一个间隔=-05:30:00当然,您可以使用to_char函数将其转换为小时和分钟,但它返回的是字符串,而不是间隔 致以最诚挚的问候,
比亚尼什么时间间隔?秒?微秒?天?年?尝试以下方法:
在时区“UTC”的“亚洲/加尔各答”选择时间戳“2020-01-13 10:00:00”代码>间隔是时间/日期差,因此不能是单个时间/日期。您的代码可以工作,但interval与此无关。也许你需要重新表述你的问题?