Oracle; dates- looking for previous month
Posted on 2006-04-13
I have this statement
(case to_char(trunc(sysdate,'mm'),'d') when '7' then trunc(sysdate,'mm')+2 when '1' then trunc(sysdate,'mm')+1 else trunc(sysdate,'mm') end) NEWDATE
That brings me back to the first business day of the month however I want to add something to this that would bring me back to the first business day of the PREVIOUS month when May 1st rolls around- or any new month actually.
So when May 1st comes- and sysdate is may 1st, I want this sql to be able to go back to April 3rd, which is the first business day of April. The same would apply for June, when June 1st comes around- i want this sql to bring the date back to May 1st which would be the first busness day of that month.
MY end in mind is to create something that I can add to scripts that I have running in oracle that would allow me to schedule them so that I do not have to change the date every new month.