oracle里如何将两个日期的时间差返回**时**分的格式

SELECT 
   EXTRACT(DAY FROM (sysdate-to_date('2012-03-29 00:00:00','YYYY-MM-DD HH24:MI:ss')) DAY TO SECOND )
   || ' days '
   || EXTRACT(HOUR FROM (sysdate-to_date('2012-03-29 00:00:00','YYYY-MM-DD HH24:MI:ss')) DAY TO SECOND )
   || ' hours'
   || EXTRACT(MINUTE FROM (sysdate-to_date('2012-03-29 00:00:00','YYYY-MM-DD HH24:MI:ss')) DAY TO SECOND )
   || ' minute'
   || EXTRACT(SECOND FROM (sysdate-to_date('2012-03-29 00:00:00','YYYY-MM-DD HH24:MI:ss')) DAY TO SECOND )
   || ' second' "Interval"
FROM DUAL;

 

SELECT 
   EXTRACT(DAY FROM (sysdate-to_date('2013-09-01 00:00:00','YYYY-MM-DD HH24:MI:ss')) DAY TO SECOND )*24+
   EXTRACT(HOUR FROM (sysdate-to_date('2013-09-01 00:00:00','YYYY-MM-DD HH24:MI:ss')) DAY TO SECOND )
   || ' hours'
   || EXTRACT(MINUTE FROM (sysdate-to_date('2013-09-01 00:00:00','YYYY-MM-DD HH24:MI:ss')) DAY TO SECOND )
   || ' minute'
   || EXTRACT(SECOND FROM (sysdate-to_date('2013-09-01 00:00:00','YYYY-MM-DD HH24:MI:ss')) DAY TO SECOND )
   || ' second' "Interval"
FROM DUAL;

 

posted @ 2013-09-02 14:57  Seaurl  阅读(531)  评论(0编辑  收藏  举报