Oracle中与时间有关的计算(二)
算相差的小时数
SQL> select round(to_number(to_date('2013-10-19 12:00:00', 'yyyy-MM-dd hh24:mi:ss') - to_date('2013-10-19 11:00:00', 'yyyy-MM-dd hh24:mi:ss')) * 24) value from dual;
VALUE
----------
1
SQL> -- 计算相差的分钟数
SQL> select round(to_number(to_date('2013-10-19 12:00:00', 'yyyy-MM-dd hh24:mi:ss') - to_date('2013-10-19 11:30:00', 'yyyy-MM-dd hh24:mi:ss')) * 24 * 60) value from dual;
VALUE
----------
30
SQL>