Thursday, February 10, 2011

Get the start and end of each month with the help of Connect by clause


SELECT     ADD_MONTHS (TRUNC (SYSDATE, 'MM'), LEVEL - 500) st_end,
           ADD_MONTHS (ADD_MONTHS (TRUNC (SYSDATE, 'MM') - 1, 1),
                       LEVEL - 500
                      ) en_date
      FROM DUAL
CONNECT BY LEVEL < 1000

No comments:

Post a Comment