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.
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.
datatimepicker怎么用,在什么地方?
还有一个问题,怎么在dbgrid中显示年月日时分,没有秒?
很EASY的问题啊 晕。。还用问
procedure TForm1.Button1Click(Sender: TObject); begin Edit3.Text:=Inttostr(HoursBetween(strtodatetime('2003-06-28 08:00' ),strtodatetime(2003-07-01 09:25’))); end;试试,很好用。两个DateTime可以用变量。
上面返回的是整数,下面返回Double:procedure TForm1.Button1Click(Sender: TObject); begin Edit3.Text:=Floattostr(HourSpan(strtodatetime(-06-28 08:00' ),strtodatetime('2003-07-01 09:25’))); end;
剩下的小数你自己机处理一下
begin
Edit3.Text:=Inttostr(HoursBetween(strtodatetime('2003-06-28 08:00' ),strtodatetime(2003-07-01 09:25’)));
end;试试,很好用。两个DateTime可以用变量。
begin
Edit3.Text:=Floattostr(HourSpan(strtodatetime(-06-28 08:00' ),strtodatetime('2003-07-01 09:25’)));
end;