![](/img/trans.png)
[英]knex js - column is of type timestamp but expression is of type character varying
[英]Compare a character varying with a timestamp
我正在尝试比较 postgresSQL 中随时间戳变化的字符。
我想获得当前时间之前的所有值与字符变化时间戳相比。
这能正确比较吗?
WHERE to_timestamp('2018-12-25T06:00:00+01:00', 'YYYY-MM-DD HH24:MI:SS') < now()
不完全是。 文字中有时区值应该被解析。 相比:
select
to_timestamp('2018-12-25T06:00:00+01:00', 'YYYY-MM-DD HH24:MI:SS') as "seems ok",
to_timestamp('2018-12-25T07:00:00+02:00', 'YYYY-MM-DD HH24:MI:SS') as "but this is wrong!",
to_timestamp('2018-12-25T06:00:00+01:00', 'YYYY-MM-DD HH24:MI:SS+TZH:TZM') as "ok",
to_timestamp('2018-12-25T07:00:00+02:00', 'YYYY-MM-DD HH24:MI:SS+TZH:TZM') as "ok too"
seems ok | but this is wrong! | ok | ok too
------------------------+------------------------+------------------------+------------------------
2018-12-25 06:00:00+01 | 2018-12-25 07:00:00+01 | 2018-12-25 06:00:00+01 | 2018-12-25 06:00:00+01
(1 row)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.