Access: FileDateTime Function

In Access, the FileDateTime function returns the date and time when a file was created or last modified.

The syntax for the FileDateTime function is:

FileDateTime( pathname )

The required pathname argument is a string expression that specifies a file name. The pathname may include the directory or folder, and the drive.

Example

FileDateTime ("C:\examples.mdb")      returns  25/05/2006 8:18:18 PM
FileDateTime ("H:\Docs\order.xls")    returns 10/10/2000 10:10:10 PM

VBA Code

Dim Result As Date 
Result = FileDateTime("C:\examples.mdb")

Now the result variable would contain the create or last modified date for the examples.mdb file. The format of the date and time displayed is based on the locale settings of your system.

SQL query

You can also use the FileDateTime function in a query.

SELECT EmployeeStatisticsTable.EmployeeIDNo, 
FileDateTime('C:\Program Files\Outlook Express\msoe.txt') AS Expr1 
FROM EmployeeStatisticsTable

Note:

This function cannot be used in expressions when Access is operating in safe mode.

admin

admin

Leave a Reply

Your email address will not be published.