Convert Time Calculation formula to script

I have a formula that I need to convert to a script…I want to schedule an agent to evaluate the last document in a view, but I don’t know how to convert it to script (because I want to get the last document).

Here is the formula:

DeliveredTime:=@Time(DeliveredDate);

TodayTime:=@Time(@Now);

Calculate:=@Round(@Integer(TodayTime-DeliveryTime)/60)

I’m trying to calculate the difference in minutes between the two fields (the time the agent runs minus the Delivered Date of a mail message). If the time is greater than 30 minutes, I want to send a mail message.

Can anyone help?

Thanks!

Melissa

Subject: Maybe this will help.

To find number of days between two dates. This code is in LotusScript.

        Code:



                  Dim doc As NotesDocument

                  Dim newDoc As NotesDocument

                  Dim weekDateTime As NotesDateTime

                  Dim creationDateTime As NotesDateTime





                  Dim ws As New NotesUIWorkspace

                  Dim uidoc As NotesUIDocument



                  Set uidoc = ws.CurrentDocument

                  Set doc = uidoc.Document



                  Set weekDateTime = New NotesDateTime( "Today" )

                  Set creationDateTime = New NotesDateTime( "" )



                  creationDateTime.LSLocalTime = doc.DateOfCreation(0)



                  difference& = (weekDateTime.TimeDifference( creationDateTime )) / 86400



                  Messagebox difference&

Dividing the result of the Timedifference by 86400 (the number of seconds in a day) will give you the number of days.

Subject: Convert Time Calculation formula to script

If ((2460Cdbl(Now)) - (2460Cdbl(doc.DeliveryTime(0)) > 30) Then

Subject: RE: Convert Time Calculation formula to script

This is giving me an error on that string:

Sub Initialize

Dim session As New NotesSession

Dim db As NotesDatabase

Dim collection As NotesDocumentCollection

Dim doc As NotesDocument

Dim i As Integer

Dim DeliveredDateValue As Variant

Dim DeliveryTime As Variant







Set db = session.CurrentDatabase

Set collection = db.UnprocessedDocuments

Set doc = collection.GetlastDocument(i)

DelliveredDateValue = doc.GETITEMVALUE("DeliveredDate")          



If ((24*60*Cdbl(Now)) - (24*60*Cdbl(doc.DeliveredDateValue(0)) > 30) Then Print FALSE Else Print TRUE

End Sub

Am I missing something?

Thanks!

Melissa

Subject: RE: Convert Time Calculation formula to script

Is DeliveredDate a date/time field or text? If it’s text, you’d need to Cdat the value.