3

In lotus I have a view with order documents. I am building an agent to search for all orders which are modified in the last 25 minutes.

For this I have done code like:

strFormule = "Form=""Order"" & @Modified >=  @Adjust(@Today;0;0;0;0;-25;0) & Deleted !=""J"""

Set ndcOrder = currentDB.Search( strFormule, Nothing, 0 )
If ndcOrder.Count <> 0 Then
Set doc = ndcOrder.GetFirstDocument
While Not doc Is Nothing

So if it is 11.00 then it need to take orders which are modified today from 10.35

But in the debugger I also get orders which where modified 2 hours earlier.

How is this possible?

Nuri Ensing
  • 1,899
  • 1
  • 19
  • 42

3 Answers3

7

I think it's might be because you're using @today which doesn't have a time element. Try @Now instead ?

user2808054
  • 1,376
  • 1
  • 11
  • 19
  • 1
    So If i want the orders from last day then i use today and if i want from the last hour or minute then i use now right? – Nuri Ensing Jan 27 '17 at 11:05
  • yes, that's right , or you could use @Date(@Modified) = @Yesterday (just compares the date part of the timestamp) for yesterday's modifications. If time of day plays a part then use @ Modified = @ Adjust(@Now;0;0;0;0;-25;0), as you say. – user2808054 Jan 27 '17 at 14:45
  • 2
    @bboni Behind the curtain, Lotus Notes stores a specific date/time as a number, and backstage, @Today = @Integer(@Now), and noon today is @Today + 0.5. (Don't try that in formula language, it won't work, but you can play with it in LotusScript if you want to.)@Today is midnight this morning. Therefore, `@Adjust(@Today;0;0;0;0;-25;0)` will always be 11:35 PM the previous night, no matter what time you do it. – JSmart523 Jan 28 '17 at 05:37
3

In the past I used the LotusScript method GetModifiedDocuments which lets you specify a NotesDateTime object to retrieve any document modified since. Your code could then look like this:

Dim session As New NotesSession
Dim db As NotesDatabase
Dim dc As notesdocumentcollection
Dim since As New NotesDateTime("")

Set db = session.CurrentDatabase
Call since.SetNow()
Call since.AdjustMinute(-25)
Set dc = db.GetModifiedDocuments(since)

My experience with this method was very good so far. More info on GetModifiedDocuments

Michael Ruhnau
  • 1,399
  • 1
  • 7
  • 15
  • Good point. Or you could use that `since` variable in the db.Search. It would be a **much** faster search that way. – JSmart523 Jan 28 '17 at 05:26
0

Why use formula at all? I would create a hidden view, first column is last modified date-time, sorted descending. Then I would write my Lotusscript code to start at the top and work its way down until it encounters a date/time value that is older than 25 minutes ago.

Something like this:

Dim docs List As NotesDocument
Set dt25 = New NotesDateEntry(Now())
Call dt25.AdjustMinutes(-25)
Dim col as NotesViewEntryCollection
Dim entry as NotesViewEntry
Set col = view.AllEntries
Set entry = col.GetFirstEntry
Do Until entry Is Nothing
    If Cdat(entry.ColumnValues(0))<Cdat(dt25.LSLocalTime) Then
        Exit Loop
    End If
    Set docs(entry.Document.UniversalID) = entry.Document
Loop
' Now you have a list of documents created in the last 25 minutes.
Karl-Henry Martinsson
  • 2,770
  • 15
  • 25