I came across the need to define the first day of next month based on the current systemdate. I can do this using the following code:
add_months(to_date(’01’||to_char(sysdate,’MMYYYY’),’DDMMYYYY’),1)
But the I remembered that there was a post on the oracledeveloper.nl forum with similar date functions.
First day of the week: select trunc(sysdate,’IW’) the_date from dual;
First day of the month: select trunc(sysdate,’MM’) the_date from dual;
First day of the year: select trunc(sysdate,’IY’) the_date from dual;
Using this information the above code could be rewritten to:
add_months(trunc(SYSDATE, ‘MM’),1)
A lot shorter and I think also better, because you don’t have to do with date masks etc.
THANK YOU SO MUCH!
YOUR ADVICES HAVE BEEN VERY HELPFUL FOR ME…A YOUNG PLSQL DEVELOPER 🙂