Hi Curtis,
>
> I am trying to calculate the diffence in two dates for example:
>
> todays date and 07/16/2005 which should give me 5.
>
> I attempted to use the daysbetween function but I believe it only works
> with two datetime values.
>
> I have a file name test07/25/2005, I like to calculate the difference
> between the file and todays date and delete the file if the date is greater
> than 365 days.
Throughout Delphi a date is expressed in a tDateTime format, which is a float
giving the
number of days since mhhh.... I thing 1899 or so with the fractional part
giving the fraction of a day (from which you can calculate the time)
FileDates are historical (compatible) DOS (yes, there was something...) formats
which aren't used on any other place exept for just files.
so to get the date of a file in a tdatetime you first retrieve the
Dos-formatted date and then have it calculated into a tdatetime var.
The corresponding functions are (have a look at Delphi's help)
Function FileAge(Const Filename:String):Integer
and
Function FileDateToDateTime(FileDate:Integer):tDateTime
To calculate the difference you can easily write
Var FileDays : Integer;
MyFileName : String;
.
.
.
FileDays := Trunc(Now - FileDateToDateTime(FileAge(MyFileName)));
Have fun
Bob
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/delphi-en/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/