Getting Last Day of Previous Month in Oracle Function

自古美人都是妖i 提交于 2019-12-01 17:20:10
Lamak
SELECT LAST_DAY(ADD_MONTHS(yourdate,-1))

As an alternative to the other answers here, you can also find the last day of the previous month by getting the day before the first day of this month

SELECT trunc(your_date, 'MM')-1 as new_date from your_table

I would probably still recommend using last_day(add_months(xxx,-1)) but just showing an alternative.

select LAST_DAY(ADD_MONTHS(sysdate, -1)) from dual;

format resulting date as you like (I'll leave that one for you ;)

With this you can also get the last BUSINESS DAY of the previous month, or any other month changing the -1.

SELECT (trunc(LAST_DAY(ADD_MONTHS(sysdate,-1)), 'iw') + 4) from dual
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!