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;

相关阅读 >>

Delphi 实现 托动pagecontrol上的标签页

Delphi 使用tmemorystream保存多张图片到文件,并读取

wmi技术介绍和应用――查询正在运行的进程信息

Delphi关于dbgrid和webbrowser的焦点问题

Delphi 判断时间是否合法 -isvaliddatetime、isvaliddate、isvalidtime、isvaliddateday

Delphi文本文件的写操作

Delphi 如何从html格式的字符串中提取纯文本?

Delphi服务器端如何防止ddos

Delphi tfdmemtable 更新到数据库

d10环境下调用hidcontroller1.0.35获取数据乱码问题

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...