Solved

FileDate to String

Posted on 1998-10-21
5
137 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 Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Suggested Solutions

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

829 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