16 Aug 2017

Generating Calendar

--GENERATING DATES FOR ONE YEAR
SELECT TRUNC(SYSDATE,'YEAR') + LEVEL-1 AS GEN_DATE
FROM DUAL
CONNECT BY TRUNC(SYSDATE,'YEAR') +LEVEL-1 < ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),12)

OUTPUT
    GEN_DATE
1 1/1/2017
2 1/2/2017
3 1/3/2017
4 1/4/2017
5 1/5/2017
...
361 12/27/2017
362 12/28/2017
363 12/29/2017
364 12/30/2017
365 12/31/2017

No comments:

Post a Comment