怎么计算两个时间的差值?

liyong00512 2003-12-07 05:01:49
是日期类型的,得到的结果是天数。
...全文
86 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
pingwing 2003-12-08
  • 打赏
  • 举报
回复
UP
jan2002 2003-12-08
  • 打赏
  • 举报
回复
DaysBetween Function

Returns the number of whole days between two specified TDateTime values.

Unit

DateUtils

Category

date/time routines

function DaysBetween(const ANow, AThen: TDateTime): Integer;

Description

Call DaysBetween to obtain the difference, in days, between two TDateTime values.

DaysBetween counts only whole days that have elapsed. Thus, DaysBetween reports the difference between Dec 31, 1999 11:59 PM and Jan 1, 2000 11:58 PM as 0 because the difference is one minute short of an entire day.
dxwin 2003-12-08
  • 打赏
  • 举报
回复
delphi帮助里:
Unit
DateUtils

Category
datetime routines

Delphi syntax:
function DaySpan(const ANow, AThen: TDateTime): Double;

Description
Call DaySpan to obtain the difference, in days, between two TDateTime values. Unlike the DaysBetween function, which only counts whole days, DaySpan reports incomplete days as a fraction of an entire day.
tglong 2003-12-08
  • 打赏
  • 举报
回复
trunc(dt2)-trunc(dt1)
senhor 2003-12-08
  • 打赏
  • 举报
回复
楼上的:
Uses
DateUtils
周江涛 2003-12-08
  • 打赏
  • 举报
回复
看这个单元,什么函数都有DateUtils
xfgncit98 2003-12-07
  • 打赏
  • 举报
回复
用DaySpan这个函数吧。
function DaySpan(const ANow, AThen: TDateTime): Double;

Returns the number of days (including fractional days) between two specified TDateTime values.Call DaySpan to obtain the difference, in days, between two TDateTime values. Unlike the DaysBetween function, which only counts whole days, DaySpan reports incomplete days as a fraction of an entire day.
sandzou 2003-12-07
  • 打赏
  • 举报
回复
var i:integer;

i:=dt2-dt1;

..............ok...........:)
sandzou 2003-12-07
  • 打赏
  • 举报
回复
var
午秋 2003-12-07
  • 打赏
  • 举报
回复
i:=trunc(dt2)-trunc(dt1);

2,495

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧