月份比较

select (to_char(to_date(?, 'yyyy-MM') +
                               (rownum - 1) * 1,
                               'yyyy-MM'))  as countdate,
                       1 as id
                  from all_objects
                 where rownum <= (to_date(?, 'yyyy-MM') -
                       to_date(?, 'yyyy-MM') + 1)

上述代码,在使用过程中,会出现月份叠加好多的现象,根本原因在于日期作差得出的差额是天数,而非月数。

猜你喜欢

转载自haishu.iteye.com/blog/1583898