用00:21>23:23 , 00:21>19:34 00:50>18:33 为何总是false 我因如何比较才能得到true .

解决方案 »

  1.   

    单纯是时间的比较的话,它就会认为是当天的0点和晚上11点做比较,当然是false啦。
      

  2.   

    用积秒的方法比较:
      积秒:相对与当天00:00:00的总秒数
            TotalSec = 时*3600+分+60+秒,取值范围 0 到 86399 秒;  规定:在20时到次日04时的时间内,积秒值小的在后,积秒值大的在前。  时间比较函数:TimeCompare   (没有测试,只是说明思路)
        TimeCompare = 0:时间参数非法
                    = 1:T1<= T2  即T1在前
                    = 2: T1 > T2  即T2在前Function TimeCompare(Const T1,T2: Dword): Integer;
    Begin
      Result:=0;
      If (T1<86400) And (T2<86400) Then
        Begin
          If (T1<=T2) Then
            Begin
              If (T1<4*3600) And (T2>20*3600) Then Result:=1
              Else Result:=2;
            End
          Else
            Begin
              If (T2<4*3600) And (T1>20*3600) Then Result:=2
              Else Result:=1;
            End;
        End;
    End
      

  3.   

    你可以用decode函数把时间给分解成年,月,日,时,分,秒
    完后从年比较,依次类推就可以了把
      

  4.   

    时间直接比较就可以了不是! if Date1>Date2 then
     showmessage('Date1 is earlier than Date2')
    else
     showmessage('Date2 is earlier than Date1');
      

  5.   

    固定时间 sTime:='08:12:12';
    if Now>Date+StrToTime(sTime) then
      

  6.   

    把時間直接加上就可
    time1d := timetostr((strtotime(time1c))+strtotime('8:30')); time2d :=timetostr((strtotime(time2c))+strtotime('8:30'));//8﹕00是表示如上班為8個小時。按需要自己調
              
        if strtotime(time2d)-strtotime(time1d)>=4 then ......//自己想怎么比怎么比
                 
        if strtotime(time2d)-strtotime(time1d)>=12 then.......