获取一段时间内所有的小时
SELECT to_date('2013-07-01 12', 'yyyy-mm-dd hh24') + (ROWNUM - 1) / 24 sdate FROM dual CONNECT BY ROWNUM <= (to_date('2013-07-02 22', 'yyyy-mm-dd hh24') - to_date('2013-07-01 12', 'yyyy-mm-dd hh24')) * 24 + 1;
获取一段时间内所有的天
SELECT to_date('2013-07-01', 'yyyy-mm-dd') + ROWNUM - 1 sdate FROM dual CONNECT BY ROWNUM <= to_date('2013-07-05', 'yyyy-mm-dd') - to_date('2013-07-01', 'yyyy-mm-dd') + 1; select to_date('2013-01-01', ' yyyy-MM-dd ') + rownum - 1 from user_objects where rownum <= (to_date('2013-01-14', ' yyyy-MM-dd') - to_date('2013-01-01 ', 'yyyy-MM-dd') + 1);
获取一段时间内所有的月
SELECT to_char(add_months(to_date('2013-01', 'yyyy-mm'), ROWNUM - 1), 'yyyy-mm') day_id FROM dual CONNECT BY ROWNUM <= months_between(to_date('2013-07', 'yyyy-mm'), to_date('2013-01', 'yyyy-mm')) + 1;