oracle 中对日期中的 年进行操作

  update safe.t_bas_device_load t set
         t.exchangetime =
               to_date(to_char(t.exchangetime, 'yyyy') - 1 || '-' ||
                       to_char(t.exchangetime, 'mm-dd hh:mi:ss'),
                       'yyyy-mm-dd hh:mi:ss')
         where t.exchangetime >=
               to_date('2017-11-17 16:59:59', 'yyyy-mm-dd hh24:mi:ss')
           and t.exchangetime <=
               to_date('2017-11-22 23:59:59', 'yyyy-mm-dd hh24:mi:ss')

 

对日期中的年份进行修改,在原日期基础上减一年。

posted on 2016-11-22 14:33  痞子斑斑  阅读(238)  评论(0)    收藏  举报