转换日期格式:
例如:转换
'20160203 16:00:00' to '2016-02-03T16:00:00'
'20160204 15:59:59' to '2016-02-04T15:59:59'
答案 0 :(得分:1)
使用to_char
:
SELECT to_char(to_timestamp('20160204 15:59:59','yyyymmdd HH24:MI:SS'),
'yyyy-mm-dd"T"HH24:MI:SS')
-- 2016-02-04T15:59:59
或:
SELECT to_char('20160204 15:59:59'::timestamp,'yyyy-mm-dd"T"HH24:MI:SS')
-- 2016-02-04T15:59:59