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 paramstr的用法

winapi 字符及字符串函数(9): lstrcat - 合并字符串

Delphi提取exe,dll文件的icon图标

Delphi richedit文字背景色的处理

Delphi 获取文件名不带扩展名

Delphi 计算一个路径相对于另一路径的相对路径

Delphi新建服务,停止系统服务,以及获取服务状态和新建系统服务器的方法

Delphi工具之tdump

Delphi xe vcl - tlinklabel(链接标签)

Delphi如何判断一个combobox是否处于下拉状态

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



打赏

取消

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

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

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

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

评论

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