View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Peter Clancy Peter Clancy is offline
external usenet poster
 
Posts: 2
Default Testing modification time of file

I want to test the modification time of a file to see whether it is more than
20 hours old. So far I have:

dim dteFileMod as Date
dim dteNow as Date
dim dteDiff as Date

'Get the date/time properties of the file
dteFileMod = FileDateTime(strFilename)
'Get date/time now
dteNow = Now
'As long as it is less than 20 hours old allow it to be used
dteDiff = dteFileMod - dteNow

I thought that a simple subtraction would work, but it hasnt. If I do a
debug print after it has run I get the following values:

dteDiff = 24/12/1899 22:25:06
dteFileMod = 14/09/2006 15:55:19
dteNow = 21/09/2006 14:20:25

Will someone please explain date/time subtraction in VB; or suggest an
easier way?
Thanks