Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

a question about the fileage function 1

Status
Not open for further replies.

bobbygm

Programmer
Mar 30, 2005
19
IT
Hi everybody,

I'm a Delphi 7 programmer.
I'm using the FILEAGE function to read the date of a file, in OS timestamp format. Can you suggest a quick way to
obtain an OS timestamp that takes only year-month-day,
without hours-minutes-seconds?
I thought that the OS timestamp could have 16 bit for
yy-mm-dd and 16 bit for hh-mi-ss, so I could do an 'and'
with 'ffff0000' (in hexadecimal) in order to bring the
hh-mi-ss bits to zero, but it's only an idea, and I
don't know how to implement it anyway.
Please help if you can!
Thank you very much,

Emanuele
 
Is this what you mean?

Code:
// getdate returns the date stamp from a file
// if it cannot read this it returns todays date.
function GetDate(filename: string): TDateTime;
var Sr: tsearchrec;
begin
   if FindFirst(Filename, faAnyFile, SR) = 0 then
       begin
          try
              Result := filedatetodatetime(SR.Time);
          except
              Result := Date;
          end;
       end
   else
      begin
         Result := Date;
      end;
   FindClose(SR);
end;

Steve: Delphi a feersum engin indeed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top