Home > Language Reference > File Functions > FileDate$

FileDate$

The FileDate$ function returns the file modification date of the specified file.

Usage

Used to know when a file has been last updated.

Syntax

var$=FileDate$(<filename>)

Parameters

<filename>, string, name of the file. 
 

Return value

var$, string. It contains the modification date (format dd/mm/yyyy). If <filename> is empty or the file does not exist, an empty string is returned. To transform the date format in a US format (mm/dd/yyyy), see example code below. 

See also

FileSize
FileTime$
FileVersion$
FileAttr$

Examples

a$=FileDate$("myfile.txt")

'Date$() returns a date with the format specified in Windows.
'Filedate$() returns the file creation date always with format dd/mm/yyyy.
'The two following functions transform from one format to the other
'************************************************************
'Conversion of file creation date to format mm/dd/yyyy
'ARGUMENT of this function is the name of the file
 
function american_filedate_date$(file$)
local da$, mon$, yea$, date_file$
 
date_file$=filedate$(file$)
da$=left$(date_file$,2)
mon$=mid$(date_file$,4,2)
yea$=right$(date_file$,4)
american_filedate_date$=mon$+"/"+da$+"/"+yea$
endfunction
 
'-------------------------------------------------------------------
'Function which gives always the current date at format dd/mm/yyyy
 
function european_date$()
local da$, mon$, yea$, date_file$
da$=day$()
mon$=month$()
yea$=year$()
european_date$=da$+"/"+mon$+"/"+yea$
endfunction
 
'-------------------------------------------------------------------------
 
'Example
 
mes$="Current date at format dd/mm/yyyy is : "+european_date$()
msgbox(mes$)
 
create("c:\wttest\bidon.txt")
mes$="File date created today at format mm/dd/yyyy is : "+american_filedate_date$("c:\wttest\bidon.txt")
msgbox(mes$)