Convert a TDateTime value to a File date/time format SysUtils unit
 function DateTimeToFileDate(DateTime TDateTime):Integer;
The DateTimeToFileDate function converts a TDateTime value DateTime to the format used for file dates.
The file date is more restricted in range than TDateTime : Year must be 1980 .. 2099 Milli-seconds are rounded to 2 decimal places
Related commands
FileAgeGet the last modified date/time of a file without opening it
FileDateToDateTimeConverts a file date/time format to a TDateTime value
FileSetDateSet the last modified date and time of a file
 Download this web site as a Windows program.

Example code : Display, update, and redisplay the last modified date of a file
  fileName    : string;
  fileDate    : Integer;
  newDateTime : TDateTime;

  // Try to open the Unit1.DCU file for the current project
  fileName := 'Unit1.DCU';
  fileDate := FileAge(fileName);

  // Did we get the file age OK?
  if fileDate > -1 then
    ShowMessage(fileName+' last modified date = '+

    // Now change the last modified date
    newDateTime := StrToDateTime('01/01/2000 12:34:56');
    FileSetDate(fileName, DateTimeToFileDate(newDateTime));

  // Did we update the file last modified date OK?
  fileDate := FileAge(fileName);
  if fileDate > -1 then
    ShowMessage(fileName+' last modified date = '+
Show full unit code
  Unit1.DCU last modified date = 30/10/2002 15:16:22
  Unit1.DCU last modified date = 01/01/2000 12:34:56
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page