Oracle日期处理

--1.Oracle查询2个月份之间的所有月份

select distinct to_char(level + to_date('2015-01-01', 'yyyy-mm-dd') - 1,

                         'yyyy-mm')

  from dual

connect by level <= to_date('2015-06-30', 'yyyy-mm-dd') -

           to_date('2015-01-01', 'yyyy-mm-dd') + 1;

           

           

--2.Oracle 两个时间相隔月数

select months_between(to_date('201511', 'yyyymm'), to_date('201509', 'yyyymm'))+1 from dual;

猜你喜欢

转载自weigang-gao.iteye.com/blog/2265681