Compare today equal to or between two dates (Lotusscript)

Hello,

I have a view that has OOO (Out of office) documents in it and a person the user is delegating their approvals to.

The document has a From and to date of type date/time and they use the calendar/time control to pick the dates. Display time is not checked. (Document properties show date as 22/05/2013 in case it is relevant.)

I am stepping through the view and comparing the next approver with an entry in the OOO View. When it finds one it checks if their OOO entry is current.

I can’t for the life of me get it to work. :frowning:

Any suggestions?

The code has had many variations - here is the latest. (Some code not relevant removed…)The date search is toward the end of the code.

Sub Click(Source As Button)

Dim workspace As New NotesUIWorkspace

Dim session As New NotesSession

Dim db As NotesDatabase

Dim uidoc As NotesUIDocument

Dim doc As NotesDocument

Dim OOOdoc As NotesDocument

Dim OOOvw As NotesView

Dim CurrentUser As String

Dim maildoc As NotesDocument

Dim rtitem As NotesRichTextItem

Dim RequestType As String

Dim CompanyName As String

Dim ApproverCount As Integer

Dim x As Variant

Dim TempApprover As Variant

Dim RoleAdd As String

Dim NewRoleUser As String

Dim NewRoleUser1 As String

Dim StateAppend As String

Dim TotalValue As Double

Dim TotalAUD As Double

Dim Subject As String

Dim MyName As String

Dim VSearch As String

’ Today Date

Dim dtToday As New NotesDateTime(Today)

Dim test1 As Integer

Dim test2 As Integer

Dim nam1 As NotesName

Dim nam2 As NotesName

Set uidoc = workspace.CurrentDocument

Set doc = uidoc.document

Set db = session.CurrentDatabase

Dim fromDate As Variant, toDate As Variant

Set pdoc = db.GetProfileDocument(“Settings”)

Dim header As NotesItem, footer As NotesItem, mailsubject As notesItem

Set header = pdoc.GetFirstItem(“NewManagerHeader”)

Set footer = pdoc.GetFirstItem(“NewManagerFooter”)

Set mailsubject = pdoc.GetFirstItem(“NewManagerSubject”)

’ See if OOO Set

’ Step through each OOO Document

Set OOOvw = db.getview(“OOO”)

Set OOOdoc = OOOvw.GetFirstDocument()

While Not (OOOdoc Is Nothing)

’ Look for a match

If (OOOdoc.OOOPerson(0) = doc.NextApprover(0)) Then

’ Found a match for the user

fromDate = OOOdoc.getItemValue(“OOOStart”)(0)

toDate = OOOdoc.getItemValue(“OOOEnd”)(0)

If Not (Typename(fromDate) = “DATE” And Typename(toDate) = “DATE”) Then

Error 9999, “From and To dates are not Date/Time”

End If

'Dim dtOOOStart As New NotesDateTime(OOOdoc.OOOStart(0))

'Dim dtOOOEnd As New NotesDateTime(OOOdoc.OOOEnd(0))

'test1 = (dtToday.TimeDifference(dtOOOStart))

'test2 = dtOOOEnd.DateOnly - dtToday.DateOnly

If fromDate >= Today() And toDate =< Today() Then

Set nam1 = doc.NextApprover(0)

Set nam2 = OOOdoc.OOODelegate(0)

Messagebox |Please note: Approver has an OOO active for today.

The approval process will be updated with the new Approver.|,64,“FYI”

'Update Approver Comments

DateasString = Format(Today, “dd/mm/yyyy”)

AddText = Cstr(DateasString) + " - OOO Agent : Approver " + nam1.Common + " Out of Office."

doc.AppComments = Arrayappend(doc.AppComments, AddText)

AddText = Cstr(DateasString) + " - OOO Agent : New approver " + nom2.OOOdoc.OOODelegate(0)

doc.AppComments = Arrayappend(doc.AppComments, AddText)

'Replace the current approver with the delegate

doc.NextApprover = OOOdoc.OOODelegate(0)

'Set the OOOdoc to the first one so the check can happen again.

Set OOOdoc = OOOvw.GetFirstDocument()

End If

End If

Set OOOdoc = OOOvw.GetNextDocument(OOOdoc)

Wend

Any help would be great!

Regards,

Glenn.