DELPHI时间相减函数


//时间相减函数
procedure TimeMinus(StartTime,EndTime:string);
var
 t,tmp:TDatetime;
 d,h,n,s:integer;
 str:string;
Begin
 t:=abs(strtodatetime(EndTime)-strtodatetime(StartTime));
 d:=round(t);
 h:=round((t-d)*24);
 tmp:=d+h/24;
 n:=round((t-tmp)*1440);
 tmp:=tmp+n/1440;
 s:=round((t-tmp)*86400);
 str:=inttostr(d)+'天'+inttostr(h)+'小时'+inttostr(n)+'分'+inttostr(s)+'秒';

{var
 S1, S2: string;
 Hour, Min, Sec, MSec: Word;
 dtRepair: TDateTime;
begin
 S1 := '2013-06-28 15:44:50';
 S2 := '2013-06-28 16:47:51';
 dtRepair := (StrToDateTime(mID[I].sEndTime) - StrToDateTime(mID[I].sBgnTime);
 ShowMessage(Format('%.02d天%.02d小时%.02d分%.02d秒', [
 Trunc(dtRepair),
 Hour,
 Min,
 Sec
 ]);

end;

联系电话:
020-00000000
联系电话:
020-00000000
联系电话:
020-12345678