同上!

解决方案 »

  1.   

    HoursBetween(const ANow, AThen: TDateTime): Int64;
      

  2.   

    你可以直接相减就可以了
    因为日期类型其实用 DOUBLE类型来存储的。
    1表示一天,1/24不就是一个小时了。
    如果是SQL中可以使用DATEDIFF 函数的,可以直接得到小时的。
    你看一下帮助就可以了。很简单的。
    DATEDIFF ( datepart , startdate , enddate ) 
    你可以使用DATEDIFF ( MI , '2003-8-1 9:34:33' , '2003-8-1 11:20:35')
      

  3.   

    如何判断两个日期型变量d1和d2之间相差多少个小时。如d1='2003-8-1 9:34:33' d2='2003-8-1 11:20:35'----------------------------------------------------------------------使用DateUtils单元提供的HourSpan函数!可以直接返回相差小时数!
      

  4.   

    Sorry,还是用一楼的HourBetween吧,那个返回值是整型的!
      

  5.   

    inttostr(HourOf(StrToDate('2003-08-01'))-HourOf(Now))
      

  6.   

    procedure TForm1.Button1Click(Sender: TObject);var
      Present: TDateTime;
      Year, Month, Day, Hour, Min, Sec, MSec: Word;
     begin
      Present:= Now;
      DecodeDate(Present, Year, Month, Day);
      Label1.Caption := 'Today is Day ' + IntToStr(Day) + ' of Month '
        + IntToStr(Month) + ' of Year ' + IntToStr(Year);
      DecodeTime(Present, Hour, Min, Sec, MSec);
      Label2.Caption := 'The time is Minute ' + IntToStr(Min) + ' of Hour '
        + IntToStr(Hour);
    end;
      

  7.   

    呵呵,不错,同意楼上的各位……double 类型,可以直接进行加减
      

  8.   

    用得差这么烦烦吗?
    d1,d2是TDateTime类型
    Showmessage(FormatDatetime('HH"小时"MM'"分钟", d1-d2))
      

  9.   

    应是
    Showmessage(FormatDatetime('HH"小时"MM"分钟"', d1-d2))
      

  10.   

    trunc((d2 - d1) * 24)
      

  11.   

    look!http://218.56.11.178:8020/web/index.aspx->下载基地->例程-经典应用->时间差计算大全
      

  12.   

    MinutesBetween(const ANow, AThen: TDateTime): Int64;
    再除以60得到小时
      

  13.   

    convert string to datetime
    then d2-d1 就是结果
    再转换为时间格式的String