两个Date类型字段:START_DATE,END_DATE,计算这两个日期的时间差(分别以天,小时,分钟,秒,毫秒):
天:
ROUND(TO_NUMBER(END_DATE - START_DATE))
小时:
ROUND(TO_NUMBER(END_DATE - START_DATE) * 24)
分钟:
ROUND(TO_NUMBER(END_DATE - START_DATE) * 24 * 60)
秒:
ROUND(TO_NUMBER(END_DATE - START_DATE) * 24 * 60 * 60)
毫秒:
ROUND(TO_NUMBER(END_DATE - START_DATE) * 24 * 60 * 60 * 1000)
例:计算分钟数
select ROUND(TO_NUMBER(to_date('2013-12-06 00:01:00','YYYY-MM-DD HH24:MI:SS')
-to_date('2013-12-05 23:58:00','YYYY-MM-DD HH24:MI:SS'))* 24 * 60)
from dual
结果为 3