注:本文来源于《 oracle 根据一个时间段获取这个时间段内所有月份、天数、日期 》
获取月份列表:
SELECT TO_CHAR(ADD_MONTHS(TO_DATE('2014-10', 'yyyy-MM'), ROWNUM - 1), 'yyyyMM') as monthlist FROM DUAL CONNECT BY ROWNUM <= months_between(to_date('2015-06', 'yyyy-MM'), to_date('2014-10', 'yyyy-MM'))
获取日期列表:
SELECT TO_CHAR(TO_DATE('2014-10-01','yyyy-MM-dd')+ROWNUM-1,'yyyyMMdd')asdaylist FROM DUAL CONNECT BY ROWNUM<=trunc(to_date('2015-06-01','yyyy-MM-dd')-to_date('2014-10-01','yyyy-MM-dd'))