我想计算两个日期相差几天,并且返回的是整数,请教如何实现:
a:integer;
time:=adoquery1.FieldByName('归还时间').asdatetime;
a:=datetoint(date()-time);
可不行,没有datetoint此函数,真是笑死,麻烦大家指点下
a:integer;
time:=adoquery1.FieldByName('归还时间').asdatetime;
a:=datetoint(date()-time);
可不行,没有datetoint此函数,真是笑死,麻烦大家指点下
DateUtils [Delphi] function DaysBetween(const ANow: TDateTime; const AThen: TDateTime): Integer;
The integral part of a Delphi TDateTime value is the number of days that have passed since 12/30/1899. The fractional part of the TDateTime value is fraction of a 24 hour day that has elapsed
小数部分是时间, 从 0 点计 1ms 的总计
按照delphi的定义,delphi中处理日期型是按照double处理的,整数部分是天数,小数部分表示时分秒,所以如果计算两日期相差几天,直接相减即可然后trunc,并且相减后数值只能是数值型的,怎么可能是date呢,呵呵
如果计算一天两个时间点相差几分钟时,可以相减后乘以24*60后再trunc即可