无拼接时:
SELECT scan_time + '5 day' FROM tbl_temp_record
SELECT scan_time + '-5 day' FROM tbl_temp_record
拼接字段时:
SELECT scan_time + 5 || ' day' FROM tbl_temp_record 报错
ERROR: operator does not exist: timestamp without time zone + integer
SQL 状态: 42883
SELECT scan_time + '5' || ' day' FROM tbl_temp_record 不是想要的结果
正确写法:
SELECT scan_time + (5 || ' day')::interval FROM tbl_temp_record
SELECT scan_time + ('-' || 5 || ' day')::interval FROM tbl_temp_record
或
SELECT scan_time + 5*interval '1 day' FROM tbl_temp_record
SELECT scan_time + 5*interval '-1 day' FROM tbl_temp_record
---------------------
作者:宫辰雅轩
来源:CSDN
原文:https://blog.csdn.net/r_rcgz/article/details/53171256
版权声明:本文为博主原创文章,转载请附上博文链接!