有没有办法将character varying
列中的rfc3339字符串正确转换为timestamp with timezone
?
Input: "2015-01-28T17:41:52Z"
Expected output: "2015-01-28 17:41:52+00"
Current output: "2015-01-28 17:41:52+01"
我尝试了以下
/* begin dummy data */
WITH messages as (
select 123 as id, '2015-01-28T17:41:52Z'::text as received
)
/* end dummy data */
SELECT id, received, (to_timestamp(received, 'YYYY-MM-DDThh24:MI:SS')) as d
FROM messages
输入数据无法添加TZ
或tz
,is available in 9.4 not in 9.3无法添加{{3}}。
答案 0 :(得分:4)
RFC3339只是ISO 8601的简介。
PostregreSQL accepts any valid ISO 8601 input为date
/ timestamp
/ timestamp with time zone
。尝试投射,如:
SELECT '2015-01-28T17:41:52Z'::timestamptz
注意:但是,您的输出(在您的客户端中)将始终位于您的current time zone。