oracle中如何取两个字符串的时间差
请教个问题:oracle中如何取两个字符串的时间差或者两个时间点的差距?
例子:2010/05/01 00:07:00 与 2010/05/01 02:44:17 如何取小时差? (也是字符类型)
或者:00:07:00 与 07:56:25 两个字符中是几个小时之差?
非常紧急,谢谢大家了.
------解决方案--------------------用to_date转换成date格式,再想减
------解决方案--------------------select floor(to_date(2010-05-01 02:44:17','yyyy-mm-dd hh24:mi:ss')-to_date('2011-05-01 00:07:00 ','yyyy-mm-dd hh24:mi:ss')) from dual;
------解决方案--------------------
------解决方案--------------------select (to_date('02:44:17','hh24:mi:ss')-to_date('00:07:00 ','hh24:mi:ss'))*24 from dual
------解决方案--------------------SQL code
SQL> edi
已写入 file afiedt.buf
1 select (to_date('2010/05/01 02:44:17','yyyy/mm/dd hh24:mi:ss')-
2* to_date('2010/05/01 00:07:00','yyyy/mm/dd hh24:mi:ss'))*1440 from dual
SQL> /
(TO_DATE('2010/05/0102:44:17','YYYY/MM/DDHH24:MI:SS')-TO_DATE('2010/05/0100:07:0
--------------------------------------------
157.283333
SQL> edi
已写入 file afiedt.buf
1 select round((to_date('2010/05/01 02:44:17','yyyy/mm/dd hh24:mi:ss')-
2* to_date('2010/05/01 00:07:00','yyyy/mm/dd hh24:mi:ss'))*24,2) from dual
SQL> /
ROUND((TO_DATE('2010/05/0102:44:17','YYYY/MM/DDHH24:MI:SS')-TO_DATE('2010/05/010
--------------------------------------------
2.62