Handy date functions…

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:


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.

One thought on “Handy date functions…

Leave a Reply

Your email address will not be published. Required fields are marked *