A little known but much easier way to get the first day of the month:
SQL> select TRUNC(SYSDATE,’MONTH’) FROM DUAL;
TRUNC(SYS
———
01-JAN-12
Much easier than the more common TO_DATE(’01-‘||TO_CHAR(v_date,’MON-YYYY’)).
It works for Year too:
SQL> select TRUNC(TO_DATE(’15-AUG-2012′),’YEAR’) FROM DUAL;
TRUNC(TO_
———
01-JAN-12