Last ModifiedDate -15 days

  • Thread starter Thread starter SteveH
  • Start date Start date
S

SteveH

I have a function which does the following:

1. Remove .xls from the file and use reminder as a wild card by
additing * at both the ends
2. Query the directory (source path) for the wild card
3. Check the data stamp on each file matching the card
4. Pick up the latest file

I now need the function to only process a file the last modified date
is less than 15days old. How can I do this?

Easy question I am sure but I cannot think of the answer.

Many thanks
SteveH
 
when you get the fie date check that like

If File_Date > Date -15 Then
...

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
Ok so I need to add to the following statement:

If oFile.DateLastModified > dtLastUpdated Then
sLatestFile = oFile.Name
dtLastUpdated = oFile.DateLastModified
End If

so it looks like :

If oFile.DateLastModified > dtLastUpdated Then
If File_Date < Date -15 Then
sLatestFile = oFile.Name
dtLastUpdated = oFile.DateLastModified
End If

I am not sure what Else clause I should put in here. Basically, if it
is older than 15days I want it to be ignored and a msgbox to be shown
saying "File needs updating" or something similar.
 
I have updatedthe following statement in my function to the following:

If oFile.DateLastModified > dtLastUpdated Then
If oFile.DateLastModified < Date - 15 Then
sLatestFile = oFile.Name
dtLastUpdated = oFile.DateLastModified
Else
MsgBox ("Spreadsheet has not been Updated")
End If
End If

When I test this by using a spreadsheet qith a LastModifiedDate of
13/07/2006 I would expect it NOT to be process and recieve the msg
above. However the file is being processed as normal.Can someone
pleeeeease tell me what is wrong with my syntax before I go nuts!

Thanks
 
You have the test the wrong way round, your test will check for files MORE
than 15 days old.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
I have switched it roudn but it still seems to be ignoring this
statement and processing anyway.
 
Back
Top