Not a difficult function to build and NotesDateTime gives us the properties and methods to determine if a document is more than x days old.
So I build the agent that compares the created date of a received document to the date of today, both transferred to a NotesDateTime class. For the today value I used the "today" function. The agent will run once a day at appr. 14:00 hrs.
Sample of the code (simplified for ease of reading)
Dim dtToday As NotesDateTime
Dim dtCompare As NotesDateTime
Set dtToday = New NotesDateTime ( Today )
Set dtCompare = New NotesDateTime ( Now )
If dtCompare.LSLocalTime <= dtToday.LSLocalTime Then
...Print 'compare date is less-equal today, send follow up'
End If
All seems to works fine if you work with documents that are older than a day (x > 0), but when we wanted to test if it worked when x = 0, no follow up emails were send.
In the sample code above I replaced the created date by "Now" but the problem is in the "Today" function.
Only when inspecting the assigned values in the debugger, you can see why it doesnot work. The "Today" function doesnot set any time value in the NotesDateTime class (see the screenshot), but in the comparison it seems to assume a time of 00:00:00 (the start of the day) and thus the follow up is not send.
To solve the problem setting dtToday to "Now" is an option, but will only partially solve the problem as it will ignore documents received after the time set by "Now" until the next day.
So instead I decided to set dtToday to the end of the day by combining the "Today" function with a fixed time string of "23:59:59".
In the (simplified) code below you can see how it works.
Set dtToday = New NotesDateTime ( Today & " 23:59:59" )
Set dtCompare = New NotesDateTime ( Now )
If dtCompare.LSLocalTime <= dtToday.LSLocalTime Then
...Print 'compare date is less-equal today, send follow up'
End If
The message I want to give here is when using NotesDateTime comparisons, carefully look at the values displayed in the debugger to see if it works the way you think it should work.
Initially I did not do this and was puzzled as to why the comparison did not work until I started looking at the assigned values of the classes in the debugger.