返回1-31,或者1-12,或者某个
select rownum from dual connect by rownum<31
就是connect by
http://marcospring.iteye.com/blog/1721600
获取某个时间段之间的月份列表(示例返回2009-03到2010-03之间的月份列表)
SELECT TO_CHAR(ADD_MONTHS(TO_DATE(‘2009-03‘,‘YYYY-MM‘),ROWNUM-1
),‘YYYY-MM‘) DAY_ID
FROM DUAL
CONNECT BY ROWNUM<=months_between
(to_date(‘2010-03‘, ‘yyyy-mm‘),to_date(‘2009-03‘, ‘yyyy-mm‘))+1
获取某个时间段的日期列表(示例返回2009-04-01到2009-05-23之间的日期列表)
SELECT TO_CHAR(TO_DATE(‘2009-04-1‘,‘YYYY-MM-DD‘)+ROWNUM-1
,‘YYYY-MM-DD‘) DAY_ID
FROM DUAL
CONNECT BY ROWNUM<=trunc(to_date(‘2009-05-23‘, ‘yyyy-mm-dd‘)-to_date(‘2009-04-1‘, ‘yyyy-mm-dd‘))+1
时间: 2024-10-18 14:00:22