Comparing dates

Below I’ve pasted the text from the help topic on lotuscript LastModified property.

I am using it and iot doesn’t seem to work. Here is my code:

days = Cint( Date - docPerson.LastModified)

This is what gets logged:

docPerson.LastModified = 03-09-30 2:37:15 PM

date = 03-10-01

days = 0

I noticed that the date formats are different. Could this be the problem? Do I have to manipulate the modified date for this to work?

Any ideas how I can resolve this?

Thanks in advanced.

Terry

Help topic text


  1. This script sets the value of the PurgeDate item in a document, based on when the document was last modified. If it was modified 14 or more days ago, it sets the PurgeDate to today. If it was modified between seven and thirteen days ago, it sets the PurgeDate to seven days from today.

Dim doc As NotesDocument

Dim days As Integer

'…set value of doc…

days = Cint( Date - doc.LastModified )

If days > 14 Then

doc.PurgeDate = Date

Else

If days > 7 Then

doc.PurgeDate = Date + 7

End If

End If

Call doc.Save( True, True )


Subject: comparing dates

Found something that seems to work.

The Now function returns “03-10-01 1:13:00 PM” and it now seems to at least give me a number of days instead of 0.

Many thanks to IBM and company for the fabulous documentation and help!?!?

Terry

Subject: RE: comparing dates

I agree that the documentation has some gaps. A more serious problem is that the gaps do not get filled. I have sent feedback to IBM about sveral errors and omissions in Designer Help, but I have never had any reply and I see that the issues are not addressed in new releases.Designer Help does say that Date returns the integer part of the date. It is less easy to find the Fix function, which removes the time part of a date/time value. So this would have worked:

days = Date - Fix(docPerson.LastModified)

Using Now might be unreliable because it contains a time. That means that you are including the times in your calculation.

Subject: RE: comparing dates

Thanks for your response. I’ll try your suggestion.

terry