Check File Date & Time In VBA

M

Mike Charney

Is there a way to check a files date and time stamp from VBA in access.

I have a need check a date stamp on a file that I am importing.

Thanks in advance,

Mike
m charney at dunlap hospital dot org
 
N

Nikos Yannacopoulos

Mike,

Try something like:

Set fso = CreateObject("scripting.filesystemobject")
Set f = fso.getfile("C:\My Documents\SomeFile.ext")
Debug.Print f.datelastmodified

HTH,
Nikos
 
D

Douglas J Steele

No need to introduce the overhead of FSO.

The VBA FileDateTime function is sufficient:

Debug.Print FileDateTime("C:\My Documents\SomeFile.ext")
 
D

Douglas J Steele

Use the DateValue function:

Debug.Print DateValue(FileDateTime("C:\My Documents\SomeFile.ext"))
 
N

Norman Yuan

Since FileDateTime function returns a value of Date type, you can get Date,
Hour, Minute or Second part from it as you wish. For example:

Debug.Print Format(FileDateTime("C:\My
Documents\SomeFile.exe"),"yyyy-MM-dd")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top