我们如何才能在甲骨文中实现上个月的记录



我是甲骨文的新手,我正在写一个查询,上个月我必须在其中获取 我的查询:

select to_char(sysdate,'MON') from dual  

但它给了我
8月,即当月。
我希望输出为上个月的 7 月

我们怎样才能实现上个月的记录。

select to_char(ADD_MONTHS (SYSDATE, -1),'MON') from dual 
--Move ahead one month: 
ADD_MONTHS (SYSDATE, 1);
--Move backward 1 month: 
ADD_MONTHS (SYSDATE, -1);  

http://www.oracle.com/technetwork/issue-archive/2012/12-jan/o12plsql-1408561.html

Oracle 数据库提供了多个用于移动日期的内置函数 按要求的金额或查找日期:

ADD_MONTHS—adds the specified number of months to or subtracts it from a date (or a timestamp) 
NEXT_DAY—returns the date of the first weekday named in the call to the function 
LAST_DAY—returns the date of the last day of the month of the specified date

最新更新