1. 程式人生 > >在PostgreSQL中可以直接對timestamp進行加減運算:

在PostgreSQL中可以直接對timestamp進行加減運算:

01.SELECT now()::timestamp + '1 year';  
02.SELECT now()::timestamp + '1 month';  
03.SELECT now()::timestamp + '1 day';  
04.SELECT now()::timestamp + '1 hour';  
05.SELECT now()::timestamp + '1 min';  
06.SELECT now()::timestamp + '1 sec';  
07.select now()::timestamp + '1 year 1 month 1 day 1 hour 1 min 1 sec';  
08.SELECT now()::timestamp + (col || ' day')::interval FROM table