s1:='12:00:00'
s2:='14:00:00'
s:=strtotime(now);
可否这样做判断:if s>s1 and s<s2 then或是:
var 
 s1,s2:TdateTime;
begin
  s1:=strtotime('12:00:00');
  s2:=strtotime('14:00:00');
  if now>s1 and now<s2 then
      ...
end;这样不行呀,请问该如何做?

解决方案 »

  1.   

    TDateTime本质是浮点类型,所以可以这样比较。
    var 
     s,s1,s2:TdateTime;
    begin
      s1:=strtotime('12:00:00');
      s2:=strtotime('14:00:00');
      s := now;
      s := s - Trunc(s);
      if (s>s1) and (s<s2) then
          ...
    end;
      

  2.   

    var
     s1,s2:TdateTime;
    begin
      s1:=strtotime('12:00:00');
      s2:=strtotime('14:00:00');
      if (comparetime(s1, now) = -1) and (CompareTime(s2, now) = 1) then
         showmessage('ok');
    end;
      

  3.   

    chechy(为程序而奋斗) 可以搞定~~~散分了:)