Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to tell the last modified date of a text file 1

Status
Not open for further replies.

neeko1226

MIS
Jul 24, 2003
82
US
I have several databases that auto import their data from .txt files dropped from the mainframe daily. I would like to code a check of the modified date of the file before I import it so I don't grab the previous days data twice. Does anyone have a way to do this? Here's my import code:

DoCmd.TransferText acImportDelim, "Cd051_Daily Import Specification", "tbl_CD051_Daily", "\\azstor01\bankops$\transfer\mainframe\fdrrpt\In\Cd051_Daily.txt", True
 
Should be achieveable thru the filesystemobject:

[tt]dim fs as scripting.filesystemobject
dim fl as scripting.file
set fs=new scripting.filesystemobject
set fl=fs.getfile("path and fullname of your file")
debug.print fl.datelastmodified
set fl=nothing
set fs=nothing[/tt]

- lots of other interesting methods and properties of filesystemobject... - needs a reference to Microsoft Scripting Runtime (in VBE - Tools | References)

Roy-Vidar
 
And what about something like this ?
MsgBox FileDateTime("\\azstor01\bankops$\transfer\mainframe\fdrrpt\In\Cd051_Daily.txt")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi Guys,

Found this which is very useful to what I am doing. However what I can't work out is how to compare the filedate to today's date to check they are the same. Easy I am sure but having tried Date=FileDateTime("...") I am now stuck.

Many thanks in advance,

GE
 
And this ?
If Int(Date) = Int(FileDateTime("...")) Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Aah. It appears not to like Date. Getting a compile error saying "Can't find project or library". Am I missing a reference?
 
When in VBE (Alt+F11):
menu Tools -> References ...
menu Debug -> Compile ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I know where the menu options are. It seems to be bombing out of the compile whenever it hits upon a built-in function eg Date or Left. I am running this at home for the first time today rather than at work. Is there a reference I need to include for it to understand built-in functions?
 
Sorted! Had nothing to do with it. Some other reference was missing.

Thanks for the tip.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top