我想求'2003-06-28 08:00' 到‘2003-07-01 09:25’之间的小时数该如何做?

解决方案 »

  1.   

    i:=(DateTimePicker1.DateTime-DateTimePicker2.DateTime)*24;
    剩下的小数你自己机处理一下
      

  2.   

    UnitDateUtilsCategorydatetime routinesDelphi syntax:function HoursBetween(const ANow, AThen: TDateTime): Int64;DescriptionCall HoursBetween to obtain the difference, in hours, between two TDateTime values. HoursBetween counts only entire hours. Thus, HoursBetween reports the difference between 9:00 AM and 9:59:59 AM as 0 because the difference is one second short of an entire hour.
      

  3.   

    UnitDateUtilsCategorydatetime routinesDelphi syntax:function HourSpan(const ANow, AThen: TDateTime): Double;DescriptionCall HourSpan to obtain the difference, in hours, between two TDateTime values. Unlike the HoursBetween function, which only counts entire hours, HourSpan reports incomplete hours as a fraction of an entire hour.
      

  4.   

    datatimepicker怎么用,在什么地方?
      

  5.   

    还有一个问题,怎么在dbgrid中显示年月日时分,没有秒?
      

  6.   

    很EASY的问题啊 晕。。还用问
      

  7.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
       Edit3.Text:=Inttostr(HoursBetween(strtodatetime('2003-06-28 08:00' ),strtodatetime(2003-07-01 09:25’)));
    end;试试,很好用。两个DateTime可以用变量。
      

  8.   

    上面返回的是整数,下面返回Double:procedure TForm1.Button1Click(Sender: TObject);
    begin
       Edit3.Text:=Floattostr(HourSpan(strtodatetime(-06-28 08:00' ),strtodatetime('2003-07-01 09:25’)));
    end;