在計算月份的時候除了add_months,還可用INTERVAL:
Connected to Oracle Database 11g Enterprise Edition Release 11.1.0.7.0<br />Connected as xxpo</p><p>SQL><br />SQL> SELECT to_char(SYSDATE,'YYYY/MM/DD HH24:MI:SS') now FROM dual;</p><p>NOW<br />-------------------<br />2011/05/20 06:22:00<br />SQL> SELECT to_char(add_months(SYSDATE,-1),'YYYY/MM/DD HH24:MI:SS') "1 month before" FROM dual;</p><p>1 month before<br />-------------------<br />2011/04/20 06:22:02<br />SQL> SELECT to_char(SYSDATE + INTERVAL '-1' MONTH,'YYYY/MM/DD HH24:MI:SS') "1 month before" FROM dual;</p><p>1 month before<br />-------------------<br />2011/04/20 06:22:04<br />SQL> SELECT to_char(SYSDATE + INTERVAL '1-1' YEAR TO MONTH,'YYYY/MM/DD HH24:MI:SS') "1 year and 1 month later" FROM dual;</p><p>1 year and 1 month later<br />------------------------<br />2012/06/20 06:22:06<br />SQL> SELECT to_char(SYSDATE + INTERVAL '-1-1' YEAR TO MONTH,'YYYY/MM/DD HH24:MI:SS') "1 year and 1 month before" FROM dual;</p><p>1 year and 1 month before<br />-------------------------<br />2010/04/20 06:22:08</p><p>SQL>