Help with Script Agent

I am trying to alter an agent. I am basically trying to do the following. I need the agent to skip all documents that are created before 07/18/2008. Problem, I am altering the script that was created and trying to mimic what it is doing with a twist. Not working. Obviously not sure what to do at this point to get it to work. Here is my code:

Dim DDay As Variant

Set DDay =New NotesDateTime (“07/18/2008 01:01:01PM”)

DeliveredDate Before 07/18/2008

If (Doc.Item(“DeliveredDate”)) < DDay Then

Call RecordLogAction( doc, "SKIP (old delivery date) - " + doc.Subject(0) )

Exit Function

End If

This is the Agent code which is working.

'Skip documents that do not have a DeliveredDate

If Not( doc.HasItem(“DeliveredDate”) ) Then

Call RecordLogAction( doc, "SKIP (no delivery date) - " + doc.Subject(0) )

Exit Function

End If

'Skip documents that do not have a PostedDate

If Not( doc.HasItem(“PostedDate”) ) Then

Call RecordLogAction( doc, "SKIP (no posted date) - " + doc.Subject(0) )

Exit Function

End If

Subject: RE: Help with Script Agent

The NotesDateTime class can’t be used with the relational operators (e.g. < ). Read about it in the help; it has a method to do comparisons. But since the date you’re comparing it to comes to you as a date/time variant, not a NotesDateTime, you might better use a variant yourself.

Do you really want to create a log record for each of the documents you’re skipping because of date? Wouldn’t it be better to do this test in the selection criteria of the agent instead, and that way your code would never even see those documents?

Subject: RE: Help with Script Agent

If you have an example I would appreciate it. Are you speaking of the agent properties? I don’t think it will work based on all the other scripting. The script is like 15 pages long. This portion is where I thought I could include the skip based on Date. Any suggestions would be great! I really need all the help I can get at this point.

Subject: RE: Help with Script Agent

No, I’m not talking about the agent properties. I mean the document selection “event” which lets you search for which documents the agent is to run on. Whether this works depends on how the agent is finding its documents now; the document selection filters the documents returned by UnprocessedDocuments.