微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

将表示时间戳的字符串转换为PostgreSQL中的实际时间戳?

在Postgresql中:我使用to_timestamp()将字符串转换为时间戳:
select * from ms_secondaryhealthcarearea
where to_timestamp((COALESCE(update_datetime,'19900101010101'),'YYYYMMDDHH24MISS') 
    > to_timestamp('20121128191843','YYYYMMDDHH24MISS')

但我得到这个错误

ERROR:  Syntax error at end of input
LINE 1: ...H24MISS') >to_timestamp('20121128191843','YYYYMMDDHH24MISS')
                                                                       ^
********** Error **********

ERROR: Syntax error at end of input
sql state: 42601
Character: 176

为什么?如何将字符串转换为时间戳?

一个太多的开口括号.试试这个:
select * 
from ms_secondaryhealthcarearea 
where to_timestamp(COALESCE(update_datetime,'YYYYMMDDHH24MISS') >to_timestamp('20121128191843','YYYYMMDDHH24MISS')

你在to_timestamp有两个左括号:

where to_timestamp((COA.. -- <-- the second one  is not needed!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐