Data type holding a date and time value System unit
  type TDateTime = type Double;
The TDateTime type holds a date and time value.
It is stored as a Double variable, with the date as the integral part, and time as fractional part. The date is stored as the number of days since 30 Dec 1899. Quite why it is not 31 Dec is not clear. 01 Jan 1900 has a days value of 2.
Because TDateTime is actually a double, you can perform calculations on it as if it were a number. This is useful for calculations such as the difference between two dates.
No local time information is held with TDateTime - just the day and time values.
Related commands
DateTimeToFileDate Convert a TDateTime value to a File date/time format
DateTimeToStr Converts TDateTime date and time values to a string
DateTimeToString Rich formatting of a TDateTime variable into a string
PDateTime Pointer to a TDateTime value
StrToDateTime Converts a date+time string into a TDateTime value
 Download this web site as a Windows program.

Example code : Finding the difference between two dates
  day1, day2 : TDateTime;
  diff : Double;
  day1 := StrToDate('12/06/2002');
  day2 := StrToDate('12/07/2002');
  ShowMessage('day1 = '+DateToStr(day1));
  ShowMessage('day2 = '+DateToStr(day2));

  diff := day2 - day1;
  ShowMessage('day2 - day1 = '+FloatToStr(diff)+' days');
Show full unit code
   day1 = 12/06/2002
   day2 = 12/07/2002
   day2 - day1 = 30 days
Delphi Programming Neil Moffatt 2002 - 2014. All rights reserved.  |  Contact the author  |  Home Page