View Single Post
  #2 (permalink)  
Old July 15th, 2005, 07:27 AM
mmcdonal mmcdonal is offline
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

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
Reply With Quote