取出当前时间上个月的最后一天
2012年的面试题,可惜没写出来啊
SQL> select sysdate from dual;
SYSDATE
-------------------
2016-11-09 09:42:44
SQL> select trunc(sysdate) from dual;
TRUNC(SYSDATE)
-------------------
2016-11-09 00:00:00
SQL> select add_months(sysdate,-1) from dual;
ADD_MONTHS(SYSDATE,
-------------------
2016-10-09 09:43:57
SQL> select last_day(add_months(sysdate,-1)) from dual;
LAST_DAY(ADD_MONTHS
-------------------
2016-10-31 09:44:22
SQL> select trunc(last_day(add_months(sysdate,-1))) from dual;
TRUNC(LAST_DAY(ADD_
-------------------
2016-10-31 00:00:00
SQL> select trunc(last_day(add_months(sysdate,-1)))-1/86400 from dual;
TRUNC(LAST_DAY(ADD_
-------------------
2016-10-30 23:59:59
SQL> select sysdate,trunc(last_day(add_months(sysdate,-1)))-1/86400 from dual;
SYSDATE TRUNC(LAST_DAY(ADD_
------------------- -------------------
2016-11-09 09:46:20 2016-10-30 23:59:59