MS Access: FileDateTime Function
This MSAccess tutorial explains how to use the Access FileDateTime function with syntax and examples.
Description
The Microsoft Access FileDateTime function returns the date and time of when a file was created or last modified.
Syntax
The syntax for the FileDateTime function in MS Access is:
FileDateTime ( file_path )
Parameters or Arguments
- file_path
- The path to a file name that you wish to retrieve the created or last modified date for.
Returns
The FileDateTime function returns a date value.
Applies To
The FileDateTime function can be used in the following versions of Microsoft Access:
- Access 2019, Access 2016, Access 2013, Access 2010, Access 2007, Access 2003, Access XP, Access 2000
Example
Let's look at how to use the FileDateTime function in MS Access:
FileDateTime ("C:\instructions.doc") Result: 6/1/2004 7:40:18 PM FileDateTime ("H:\Documents\Supplies.xls") Result: 7/3/2004 3:12:14 PM
Example in VBA Code
The FileDateTime function can be used in VBA code in Microsoft Access.
For example:
Dim LResult As Date LResult = FileDateTime ("C:\instructions.doc")
In this example, the variable called LResult would now contain the create or last modified date for the instructions.doc file.
Example in SQL/Queries
You can also use the FileDateTime function in a query in Microsoft Access.
For example:
In this query, we have used the FileDateTime function as follows:
FileDateTime("C:\instructions.doc")
This query will return the date and time of when the instructions.doc file was last modified. The results will be displayed in a column called Expr1, since no column name was specified. You can replace Expr1 with a column name that is more meaningful.
For example:
FileInfo: FileDateTime("C:\instructions.doc")
The results would now be displayed in a column called FileInfo.
Advertisements