Ahhhh after running this successfully for a month from 14/08/2008 I discovered a blip when the day changes from 9 th to the 10th (Discovered this on the 9/11/2008 which spooked me a bit ) The DateCheck function can not handle the extra digit on the expiration num and deletes the new files rather than the old files. However this is inconsistant as the results from my log file show:
-----------------------------------------------
YToday num =2008
MToday num =9
DToday num 15
YExpiration num = 2008
MExpiration num = 9
DExpiration num =14
lastmodified num = 200899
Expiration Num =2008914
DateCheck new
YToday num = 2008
MToday num = 9
DToday num =15
YExpiration num =2008
MExpiration num = 9
DExpiration num =14
lastmodified num =200888
Expiration Num = 2008914
database deleted = mydatabase_db_200808081830.bak,8/8/2008 6:30:02 PM
-------------------------------------
LastmodifiedNum < ExpirationNum
Why Then is 200888 < 2008914 correct but 200899 < 2008914 is not correct ?
I have amended the function to use DateDiff this is working well so far.
Function DateCheck(Lastmodified)
DiffADate = DateDiff("d", Lastmodified,Date )
LogFile.Writeline "Date difference = " & " " & DiffADate
If DiffADate > Days then
DateCheck="old"
LogFile.Writeline "DateCheck " & "" & DateCheck
else
DateCheck="new"
LogFile.Writeline "DateCheck " & "" & DateCheck
end if
end Function
Will keep you posted of my progress.
Cheers
Lizzy