我有一个数据库begtime保存开始时间,endtime保存结束时间
如:
begtime    endtime
3:00:00    4:00:00
8:00:00    9:00:00
我想判断现在的时间是否在3:00:00-4:00:00和8:00:00-9:00:00之间,
请问怎么做才好呢?

解决方案 »

  1.   

    我不知道你最后要实现什么功能,但是我们知道日期型其实就是实数型。那么可以通过数字的比较实现判别;参考:
    select trunc(sysdate,'mi') from dual;---精确到分钟那么
     select trunc(sysdate,'mi')-trunc(sysdate) from dual;;---得到的是一个小数,表示当天时间,精确到分钟。但是这个方法不太好。
      

  2.   

    其实另外也可以把数据表的时间(假定是字符串型)转为时间比较就是了。select to_date('3:00','hh:mi') from dual;然后在过程里比较,if sysdate>to_date('3:00','hh:mi') then ......
      

  3.   

    精确到秒只要将‘mi’ 改‘ss’.
      

  4.   

    可以  (时间1<now and now<时间2) or ()
      

  5.   

    if 时间>=begtime  and  时间<=  endtime then
      ...
      

  6.   

    他的意思好象是要在oracle里解决。如果放到delphi当然好解决了....
      

  7.   

    declare @intcount
    select @intcount=count(*) from datetime between begtin adn endtime
    if@intcount>0   
      ****************************