|
--获取日期列表
select to_char(to_date('2014-10-01', 'yyyy-MM-dd') + rownum - 1, 'yyyyMMdd') as daylist
from dual
connect by rownum <=
trunc(to_date('2015-10-01', 'yyyy-MM-dd') -
to_date('2014-10-01', 'yyyy-MM-dd')) + 1;
--获取月份列表
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-10', 'yyyy-MM'),
to_date('2014-10', 'yyyy-MM')) + 1;
--获取年份列表
select to_char(add_months(to_date('2014-10', 'yyyy-MM'), (rownum - 1) * 12),
'yyyy') as yearlist
from dual
connect by rownum <=
months_between(to_date('2015-10', 'yyyy-MM'),
to_date('2014-10', 'yyyy-MM')) / 12 + 1;
|
|