`

月份比较

 
阅读更多
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)

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

相关推荐

Global site tag (gtag.js) - Google Analytics