FileDateTime

Gets time and date for a file, Date created, accessed or modified. If the file is not found or an error occurs during the processing of the function, Null is returned.
WhichDate = 1 to return Date created
WhichDate = 2 to return Date last accessed
WhichDate = 3 or anything else, to return date last modified

CodeFunctionName
What is this?

Public

Tested

Original Work
Function FileDateTime(pathname, WhichDate)
' WhichDate can be 1, 2, 3
' 1 DateCreated, 2 = DateAccessed, 3 = DateModified
On Error Resume Next
' Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(pathname)
If Err Then
FileDateTime = Null
Else
FileDateTime = CDate( objFile.DateLastModified )
If WhichDate = 1 Then
FileDateTime = CDate( objFile.DateCreated )
ElseIf WhichDate = 2 Then
FileDateTime = CDate( objFile.DateLastAccessed )
End If
End If
Set objFile = Nothing
On Error GoTo 0
End Function

pathname, WhichDate

Views 4,141

Downloads 1,337

CodeID
DB ID