服务器 频道

oracle时间间隔问题

  【IT168 服务器学院】关于从oracle取得两个时间间隔的问题。
我所做的是,得到具体的分钟数:
  1、  select 86400*(to_date(''2006-04-05 12:36:43'',''yyyy-mm-dd hh24:mi:ss'')-to_date(''2006-04-05 11:33:23'',''yyyy-mm-dd hh24:mi:ss''))/60
from dual;

  2、  具体取值,与当前时间的比值:
       select (86400*(sysdate - max(mdate))/60) as minute from table where (.....) ; 
       max(mdate)为从table中取得的字段名为mdate的最大时间值。

  如上面的方法即可得到相间隔的分钟数。在oracle数据库中一条语句就搞定了,若用程序实现要费好多事,浪费字节数。。。。呵呵〉
0
相关文章