如下:
SQL> select sysdate-to_date('2013-08-11 18:30:59','yyyy-mm-dd hh24:mi:ss')ts from dual;
TS
----------
901.764444
注:此处得到的是天
SQL> select '两个时间相差:'AS 时间,
2 trunc(to_number(sysdate -to_date('2013-08-11 18:30:59','yyyy-mm-dd hh24:mi:ss')))天,
3 trunc(mod(to_number(sysdate -to_date('2013-08-11 18:30:59','yyyy-mm-dd hh24:mi:ss'))*24*60,1440)/60) 小时,
4 trunc(mod(to_number(sysdate -to_date('2013-08-11 18:30:59','yyyy-mm-dd hh24:mi:ss'))*24*60*60,3600)/60)分钟,
5 trunc(mod(to_number(sysdate -to_date('2013-08-11 18:30:59','yyyy-mm-dd hh24:mi:ss'))*24*60*60,60))秒
6 from dual;
时间 天 小时 分钟 秒
-------------- ---------- ---------- ---------- ----------
两个时间相差: 901 18 21 4
分别得到 天 时 分 秒