我想比较两个时间段.比如判断是不是在早上8点到晚上6:30之间.怎么判断阿.
另外问个附加的问题,睡觉总做梦飞来飞去的怎么回事啊.

解决方案 »

  1.   

    now里面有没有毫秒,不记得了
    时间判断可以用formatdatetime('hh',now) 得到小时来判断另外,我从小就常做梦在飞,呵呵
      

  2.   

    var
      s:string;s:=FormatDateTime('hh:nn:ss',now());
    if (s>'08:00:00') and (s<'18:30:00') then
       begin
          //你想干吗...
       end;
    //第二个问题,难道是中风的前兆? (开个玩笑 0_o   )
      

  3.   

    取当前时间用now;
    比较日期;CompareDate
    其他函数可以看帮助(Datetime
      

  4.   

    取毫秒:
    function MilliSecondOf(const AValue: TDateTime): Word;
      

  5.   

    转化为字符串判断不是很好, 效率比较低
    TDateTime 实际为一 Double 类型, 其用整数部分表示天数, 小数部分表示时间dt: TDateTime;则时间部分为 t := dt - Trunc(dt);早上8点到晚上6:30之间则可以如下判断
    if (t >= 8.0 / 24.0) and (t <= 18.5 / 24.0) then
    begin
    end;