无拼接时:

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

————————————————