function DateTimeDiff(dtp1,dtp2:TDateTimePicker):double; //多少天含時間差
begin
result:=dtp1.DateTime-dtp2.DateTime;
end;
function DateDiff(dtp1,dtp2:TDateTimePicker):integer; //多少天
begin
result:=dtp1.DateTime-dtp2.DateTime;
end;
see also constance part of SysUtils.pas
-----------------------
{ Units of time }
HoursPerDay = 24;
MinsPerDay = HoursPerDay * 60;
SecsPerDay = MinsPerDay * 60;
MSecsPerDay = SecsPerDay * 1000;
{ Days between 1/1/0001 and 12/31/1899 }
DateDelta = 693594;
{ Days between TDateTime basis (12/31/1899) and Unix time_t basis (1/1/1970) }
UnixDateDelta = 25569;
oh! datetimepicker1.DataTime 是TDataTime類.
According to HelpFile, we got....
type TDateTime = type Double;
The integral part of a TDateTime value is the number of days that have passed since 12/30/1899.
The fractional part of a TDateTime value is fraction of a 24 hour day that has elapsed.
Hence, Trunc(datetimepicker1.DateTime-datatimepicker2.DateTime) got 4 or 5 according to the Time Part!
Good Luck!