Solved

FileDate to String

Posted on 1998-10-21
5
132 Views
Last Modified: 2011-09-20
how to convert FileDate to String ?
0
Comment
Question by:omsec
  • 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Delphi XE10, MySQL Query 4 109
delphi parse string to params 3 82
JAudiorecorder record freezing the app 30 35
Base1 Encode/Decode 3 35
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now