Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

FileDate to String

Posted on 1998-10-21
5
Medium Priority
?
142 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

636 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