Solved

FileDate to String

Posted on 1998-10-21
5
138 Views
Last Modified: 2011-09-20
how to convert FileDate to String ?
0
Comment
Question by:omsec
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
ZifNab earned 0 total points
ID: 1343629
Hi omsec,

you can do the following :

convert it to TDateTime and then convert it to string :

e.g.

function FileDateToDateTime(FileDate: Integer): TDateTime;
procedure DateTimeToString(var NewString: string; const Format: string; DateTime: TDateTime);

Or

FileDate is integer, so just convert integer to string :

function IntToStr(Value: Integer): string;

But I guess the first proposal is more appropriate.

Regards, ZiF.
0
 
LVL 2

Author Comment

by:omsec
ID: 1343630
i know the first function, but what's FileDate : Integer ? Where does it come from, shouldn't there be a function that expects a File - Var ?
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1343631
Ah,

I thought you already had the date of a file because your talking about FileDate.

You can get the FileDate with FileGetDate or through the Time field of the TSearchRec.

e.g.

procedure TForm1.Button1Click(Sender: TObject);
var SearchRec : TSearchRec;
    Date_of_File : TDateTime;
    stDate_of_file : shortstring;
begin
if OpenDialog1.Execute then begin
  FindFirst(Opendialog1.FileName, faAnyFile, SearchRec);
  Date_of_file := FileDateToDateTime(searchRec.Time);
  stDate_of_file := DateToStr(Date_of_file);
  showmessage(stDate_of_file);
 end;
end;

You can make it shorter offcourse.

Zif.
0
 
LVL 2

Author Comment

by:omsec
ID: 1343632
i don't have a TSearch-Object, it's a simple File Handle (untyped FILE) So how to get the time from this ?
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1343633
then you need to use FileDate := GetFileDate({handle})
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question