`

月日比较

    博客分类:
  • sql
阅读更多
select substr(('0' || Extract(MONTH from ins.t_end_date)), 2) ||
       substr(('0' || Extract(DAY from ins.t_end_date)), -2),
       substr('0' ||
              Extract(MONTH from
                      to_date(to_char(add_months(sysdate, 3), 'yyyy-mm-dd'),
                              'yyyy-mm-dd')),
              2) ||
       substr('0' || Extract(DAY FROM to_date(to_char(add_months(sysdate, 3),
                                             'yyyy-mm-dd'),
                                     'yyyy-mm-dd')),
              2)
  from tb_ins_info ins
 where ins.c_del = '0'
   and ins.c_stat = '99'
   and ins.c_cst_id = '23'
   and substr(('0' || Extract(MONTH from ins.t_end_date)), 2) ||
       substr(('0' || Extract(DAY from ins.t_end_date)), -2) <=
       substr('0' ||
              Extract(MONTH from
                      to_date(to_char(add_months(sysdate, 3), 'yyyy-mm-dd'),
                              'yyyy-mm-dd')),
              2) ||
       substr('0' || Extract(DAY FROM to_date(to_char(add_months(sysdate, 3),
                                             'yyyy-mm-dd'),
                                     'yyyy-mm-dd')),
              2)
   and ins.t_end_date > sysdate
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics