Postgres char(14) 字段存储没有分隔符的日期时间,例如 20131124112907
如何添加分隔符使结果为字符串格式
2013-11-24 11:29:07
我尝试使用 Denis 回答
to_timestamp(timestamp, 'YYYYMMDDHHMISS')::text as updated_at
但有异常
Message=ERROR: 22007: hour "15" is invalid for the 12-hour clock
Code=22007
File=src\backend\utils\adt\formatting.c
Hint=Use the 24-hour clock, or give an hour between 1 and 12.
最佳答案
您可以使用 to_date()
或 to_timestamp()
转换它:
select to_timestamp('20131124112907', 'YYYYMMDDHH24MISS')
关于sql - 如何将 YYYYMMDDHHMMSS 转换为 2013-11-24 11 :29:07 in postgres,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20180460/