zoukankan      html  css  js  c++  java
  • oracle 日期相减

    ------------------------------------------------------------------------------------------------------------------------------------------
    date类型:
    时间戳格式:
    SQL> desc t100;
    Name    Null?    Type
    ----------------------------------------- -------- ----------------------------
    STARTTIME     DATE
    ENDTIME     DATE
    
    create table t100(starttime date, endtime date);
    
    
    insert into t100 values(to_date('2018-04-11 18:00:07', 'yyyy-mm-dd hh24:mi:ss'),to_date('2018-04-11 18:00:15', 'yyyy-mm-dd hh24:mi:ss'));
    
    CREATE OR REPLACE FUNCTION esbtimediff(t1  timestamp,
    t2 timestamp)
    return number is
    BEGIN
    if (length(t1)!=0 and length(t2)!=0) then
      return TO_NUMBER(substr(substr((T1-T2),15,9),0,2))*60*1000 + TO_NUMBER(substr(substr(T1-T2,15,9),4))*1000;
    else
       return 0;
    end if;
    end;
    
    
    SQL> select starttime,endtime ,esbtimediff(endtime,starttime) from t100;
    
    STARTTIME     ENDTIME ESBTIMEDIFF(ENDTIME,STARTTIME)
    ------------------- ------------------- ------------------------------
    2018-04-11 18:00:07 2018-04-11 18:00:15    8000
    
    
    
    varchar2型:
    SQL> select starttime,endtime ,esbtimediff(to_date(endtime,'yyyy-mm-dd hh24:mi:ss'),to_date(starttime,'yyyy-mm-dd hh24:mi:ss'))  from t200;
    
    STARTTIME      ENDTIME
    ------------------------------------------------------------ ------------------------------------------------------------
    ESBTIMEDIFF(TO_DATE(ENDTIME,'YYYY-MM-DDHH24:MI:SS'),TO_DATE(STARTTIME,'YYYY-MM-DDHH24:MI:SS'))
    ----------------------------------------------------------------------------------------------
    2018-04-11 18:00:07      2018-04-11 18:00:15
       8000
    
  • 相关阅读:
    jquery easyui DataGrid
    easyui datagrid使用
    easyui中datagrid用法,加载table数据与标题
    目前已有的框架
    CSS 块级元素、内联元素概念
    设计中最常用的CSS选择器
    ASP.NET MVC 学习
    CSS边框-属性详解
    Boostrap入门级css样式学习
    Codeforces Round #261 (Div. 2)——Pashmak and Graph
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348339.html
Copyright © 2011-2022 走看看