VBA FileDateTime function

FileDateTime Function Description

The VBA FileDateTime function returns the date and time of when a file or directory was created or last modified. The FileDateTime functions works for both files and directories.

Syntax

The syntax for the FileDateTime function in VBA is:

FileDateTime ( file_path )

Parameters

file_path
The path to a file name that you wish to retrieve the created or last modified date for.

Other Notes

The FileDateTime function will return a Date Data Type variable. Use the Format Function to format the date appropriately.

Example usage

The FileDateTime function can be used in VBA. Let’s look at some FileDateTime function examples:

FileDateTime "C:\test.txt"
Result: 2015-01-07 20:50:50 

FileDateTime "C:\Program Files"
Result: 2012-01-07 12:51:22