@BusinessDays equivalent in LotusScript

I need to calculate the age of a password value in a document. Using this formula in the field: @BusinessDays(StartDate; EndDate)

works correctly, however it doesn’t get recalculated in the view the next day unless the document is actually opened/closed. I need this value to be recalculated daily and the new value to appear in a view without the users having to open every document they own.

Is there a way to do the @BusinessDays formula function from a scheduled LotusScript agent?

I’ve tried this code in an agent:

SearchStr0={(Form = “System”)}

Set pwageupdt=db.Search (SearchStr0,Nothing,0)

If pwageupdt.count > 0 Then

Set docpw=pwageupdt.getfirstdocument

While Not docpw Is Nothing

Set EndDate = New NotesDateTime(Today)

If docpw.PWCreateDT(0) = "" _

And docpw.PWChangeDT(0) = "" Then  'no PW set

  savedocpw="No"

Elseif docpw.PWCreateDT(0) <> "" _

And docpw.PWChangeDT(0) = "" Then  'new doc w/pw

  Set StartDate = New NotesDateTime (docpw.PWCreateDT(0))				 savedocpw="Yes"

Elseif docpw.PWCreateDT(0) <> "" _

And docpw.PWChangeDT(0) <> "" Then    'pw has been changed

  Set StartDate = New NotesDateTime (docpw.PWChangeDT(0))					savedocpw="Yes"

End If

			

If StartDate.DateOnly = EndDate.DateOnly And docpw.Password(0) <> "" Then	

  docpw.PWAge = "1"     'pw is 1 day old

Else		

  new_pwage = {@BusinessDays(StartDate; EndDate)}		    'get pw age	

  docpw.PWAge = new_pwage

End If

			

If savedocpw="Yes" Then

  Call docpw.Save(True,True)

End If



savedocpw="No"

Set docpw=pwageupdt.getnextdocument(docpw)

Wend

End If

But I’m not getting the results I need. How can I do this in a daily scheduled agent?

Any help is greatly appreciated. Thank You.

Subject: Try using Evaluate

e.g.

new_pwage = Evaluate(|@BusinessDays([| & StartDate.DateOnly & |];[| & EndDate.DateOnly & |])|)

docpw.PWAge = CInt(new_pwage(0))

Subject: better with evaluate

rather than creating 100 lines of code, better to use evaluate function.http://www.indomino.net/blog/2009/10/03/evaluate-the-bridge-between-lotus-script-and-formula/