计算oracle数据库字符串时间秒差值

来源:互联网 发布:淘宝网注册帐号银行卡 编辑:程序博客网 时间:2024/06/06 05:53

1 原始数据


select t.record_date as rq,

       t.cal_current_status as curZT,
       round(to_number(to_date(to_char(t.cal_current_end_time,
                                       'yyyy/mm/dd hh24:mi:ss'),
                               'yyyy/mm/dd hh24:mi:ss') -
                       to_date(to_char(t.cal_current_begin_time,
                                       'yyyy/mm/dd hh24:mi:ss'),
                               'yyyy/mm/dd hh24:mi:ss')) * 24 * 60,
             2) as curTime,
       t.cal_series_status as serzt,
       round(to_number(to_date(to_char(t.cal_series_end_time,
                                       'yyyy/mm/dd hh24:mi:ss'),
                               'yyyy/mm/dd hh24:mi:ss') -
                       to_date(to_char(t.cal_series_begin_time,
                                       'yyyy/mm/dd hh24:mi:ss'),
                               'yyyy/mm/dd hh24:mi:ss')) * 24 * 60,
             2) as serTime
  from tb_lh_ug_import_status t

 order by record_Date

2 格式化后数据

3 *24代表求小时差,*24*60代表求分钟差,*24*60*60代表求秒差

select to_number(to_Date('2017/8/4 0:04:14','yyyy/mm/dd hh24:mi:ss')-to_Date('2017/8/4 0:03:17','yyyy/mm/dd hh24:mi:ss'))*24*60*60 from dual;

原创粉丝点击