2 Answers
2

When you create a datetime value without a time portion in VBScript, the time is automatically assumed to be 00:00:00 (see for instance the return value of TimeValue(Date)). Because of this DateDiff() compares the "last modified" timestamp of the file with the current date at 00:00:00 and returns a value greater than 1 (or less than -1) when the difference exceeds ±24 hours.

For comparing just the date parts of two timestamps use the FormatDateTime() function:

today = FormatDateTime(Date, vbShortDate)
If FormatDateTime(RFile.DateLastModified, vbShortDate) = today Then
'...
End If

Thanks, Could you possible think of a scenario where DateDiff("d",RFile.DateLastModified ,Date) will not be equal to zero while I can manually see that all files have today as the DateModefied ?
–
Akshay JNov 5 '12 at 8:31