oracle查询日期列表

--月份
SELECT TO_CHAR(ADD_MONTHS(SYSDATE, - (ROWNUM - 1)), 'yyyy-mm') yyyymmdd
FROM DUAL CONNECT BY ROWNUM < MONTHS_BETWEEN(SYSDATE, TO_DATE ('201711', 'yyyymm'))+1
--select to_char(sysdate-(ROWNUM-1),'yyyymmdd') from dual
CONNECT BY ROWNUM < SYSDATE-(TO_DATE ('20171104', 'yyyymmdd'))+1

 

posted @ 2018-03-23 10:07  巴啦啦大魔王  阅读(460)  评论(0编辑  收藏  举报