在PostgreSQL中可以直接對時間進行加減運算:、
SELECT now()::timestamp + '1 year'; --當前時間加1年
SELECT now()::timestamp + '1 month'; --當前時間加一個月
SELECT now()::timestamp + '1 day'; --當前時間加一天
SELECT now()::timestamp + '1 hour'; --當前時間加一個小時
SELECT now()::timestamp + '1 min'; --當前時間加一分鍾
SELECT now()::timestamp + '1 sec'; --加一秒鍾
select now()::timestamp + '1 year 1 month 1 day 1 hour 1 min 1 sec'; --加1年1月1天1時1分1秒
SELECT now()::timestamp + (col || ' day')::interval FROM table --把col字段轉換成天 然后相加