Description |
The DaySpan function subtracts the FromDate from the ToDate, returning the fractional days difference.
The Double return value contains the number of days as the integral part, and the part-day remainder as the fractional part.
For example, a difference of 2 days and 6 hours would give a value of 2.25
|
|
Related commands |
|
|
|
Example code : Find the days difference between two date+time values. |
var
fromdate, toDate : TDateTime;
begin // Set up our date variables
fromDate := EncodeDateTime(2000, 01, 01, 0, 0, 0, 0);
toDate := EncodeDateTime(2000, 01, 02, 12, 0, 0, 0);
// Display these dates and the days between them
WriteLn('From date = '+DateTimeToStr(fromDate));
WriteLn('To date = '+DateTimeToStr(toDate));
WriteLn('Fractional days difference = '+
FloatToStr(DaySpan(toDate, fromDate))+' days');
end;
|
Show full unit code |
From date = 01/01/2000
To date = 02/01/2000 12:00:00
Fractional days difference = 1.5 days
|
|