Hi,
This will get you your file DateCreated:
'----------
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("C:\data.csv")
stLongDate = objFile.DateCreated
DateArray = Split(stLongDate, " ")
stShortDate = DateArray(0)
WScript.Echo stShortDate
'----------
objFile.DateCreated is the date and time the file was created. I split it using the space between the date and time to get just the date. I used a file called C:\data.csv that I use for filesystem tests.
You can use this code in your access code. I am assuming you will know the path to the file you are working with. If so, then capture the path in a variable, and rewrite the code like this:
'----------
Dim stPath As String
stPath = "C:\data.csv"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(stPath)
stLongDate = objFile.DateCreated
DateArray = Split(stLongDate, " ")
stShortDate = DateArray(0)
WScript.Echo stShortDate
'----------
Then just pass stShortDate in your code to addnew to your table.
HTH
mmcdonal
|