Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在postgresql中将时间戳转换为间隔_Postgresql - Fatal编程技术网

在postgresql中将时间戳转换为间隔

在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。似乎您正在尝试获取特定时间两个时

我正在尝试将时间戳转换为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'
        -  
        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与此无关。也许你需要重新表述你的问题?