Lotus script document created property strange behavior - lotus-notes

I'm currently using the domino desginer 8.5.2 and I encountered a strange thing related to the notesdocument Created property.
I'm trying to create an agent in lotusscript that selects some documents based on their Created date.
I have the following test code where doc is a NotesDocument in a specific NotesDatabase:
If doc.Created < DateNumber(1951,1,1) Then
Print "old"
End If
The issue is that there are no documents in the DB that are older than 2010 yet the code above Prints "old" for some documents (like 10 in 5k), but when I enter the debugging session and check the doc's Created property in the Variables window it's a normal date like 2012. 02. 03. or smth.
Another interesting note is that if I try to write the Created date into a csv file it's a nonsense date like 1896. 06. 20. but then again when I check the property while debugging it's completely normal.
Have you encountered this issue before? Or am I comparing dates in the wrong way?
----EDIT1------------
I oversimplified the question, I'm really sorry if it was misleading I can only humbly ask you to keep the ideas comming because solving this issue is crucial.
The agent in question does not process it's own documents, it's opening multiple databases on the server (a lot of ppl's mail databases) and processing documents (emails) by multiple conditions. What we actually do is this:
strFileName = "D:\temp\log.csv"
Set nStream = session.CreateStream()
nStream.Open(strFileName)
nStream.Truncate
Dim deleteCutoffDate As New NotesDateTime("Today")
Dim moveCutoffDate As New NotesDateTime("Today")
Dim tmp As Integer
tmp = settingsDto.GetDeleteOlderThanMonths()
Call deleteCutoffDate.Adjustmonth((-1)*tmp, True)
searchForm$ = {Form = "Memo" }
Set doccol = db.Search(searchForm, Nothing, 0) 'db is an opened NotesDatabase
Set doc = doccol.GetFirstDocument
While Not doc Is Nothing
Dim nextDoc As NotesDocument
Set nextDoc = doccol.Getnextdocument(doc)
'Earlier condition we tried
'If doc.Created < deleteCutOffDate.Lslocaltime
' deleteCutoffDate is today - 3 years
If (Fix( doc.Created ) < Fix( CDat(deleteCutoffDate.Dateonly))) Then
'Suggested solution to check dates
Dim longTemp As Long
longTemp = Fix( CDat(deleteCutoffDate.Dateonly)) 'should be 36,647 (#days from Dec 30, 1899 to May 1, 2000)
longTemp = Fix( doc.Created ) 'check this number makes sense (see last line)!
'This is only for logging, testing.
Dim temp As String
temp = Format( doc.Created, "yyyy-mm-dd")+";"+doc.Noteid+";"
Call nStream.WriteText(temp,EOL_PLATFORM)
'******* Processing logic goes here **********
End If
Set doc = nextDoc
Wend
Call nStream.Close()
So the problem and the symptoms I saw so far:
Some documents (always the same) have weird Creation dates. Let's say we have 3 documents A, B, C.
When I write document A's Created property to csv it says 1899-12-30 when I check the debugger the doc.Created is 2015-01-06 which is the correct date but Fix( doc.Created ) is 0. This makes no sense. This sould not pass the if condition and be written into csv acording to Fix beeing 0 yet is does.
Document B's date is 1899 in csv, debugger says 2015-10-25, Fix( doc.Created ) reports the correct number BUT this document should not have gone through the If condition since the if only allows a pass for documents older than 3 years starting from today. So if i run the script on '18-02-07 documents created before 15-02-07 should pass the condition.
Document C's date is 4916-04-18 everything else is the same as above
These issues apper on multiple (but always on the same) documents. But these are not special documents or anyting they are simple emails
Another thing I noticed is if I run the script multiple times in a row (without debugging or interfering) sometimes the CSV reports the correct dates! For me this suggests some sort of a reference issue but at this point i'm not sure how the world works.
Note that there are no other processing logic is involved, all the logic inside the If condition have been commented out that manipulated the documents. Test database has been restored to it's original state
If you have any ideas please don't hold back I am stuck on this issue for days now.
Thanks

It looks like what you are trying to do should work fine. I think the created date comes from a part of the doc universal id, so if that was set programatically it would be possible to see docs with creation dates that looked very old.
I would suggest trying the following to see if you can spot where the issue is
dim longTemp as long
dateTemp = cdat( "May 1, 2000" )
longTemp = Fix( dateTemp ) 'should be 36,647 (#days from Dec 30, 1899 to May 1, 2000)
longTemp = Fix( doc.Created ) 'check this number makes sense (see last line)!
If doc.Created < dateTemp then
print "old"
end if
Re writing doc.created to a csv file, I would suggest formatting it as text before writing, so
format( doc.created, "yyyy-mm-dd") 'or your preferred date format

I give up. Time to punt and suggest workarounds! Might any of these work?
Workaround 1: Formulas
Instead of an if block, build the date criteria within the search formula for doccol. This is probably faster anyway.
strFileName = "D:\temp\log.csv"
Set nStream = session.CreateStream()
nStream.Open(strFileName)
nStream.Truncate
Dim deleteCutoffDate As New NotesDateTime("Today")
Dim moveCutoffDate As New NotesDateTime("Today")
Dim tmp As Integer
tmp = settingsDto.GetDeleteOlderThanMonths()
Call deleteCutoffDate.Adjustmonth((-1)*tmp, True)
searchForm$ = {Form = "Memo" & #Created < [} + deleteCutoffDate.LocalTime + {]} '<--- removed if block and put criteria checking here
Set doccol = db.Search(searchForm, Nothing, 0) 'db is an opened NotesDatabase
Set doc = doccol.GetFirstDocument
While Not doc Is Nothing
Dim nextDoc As NotesDocument
Set nextDoc = doccol.Getnextdocument(doc)
'Earlier condition we tried
'If doc.Created < deleteCutOffDate.Lslocaltime
' deleteCutoffDate is today - 3 years
'Suggested solution to check dates
Dim longTemp As Long
longTemp = Fix( CDat(deleteCutoffDate.Dateonly)) 'should be 36,647 (#days from Dec 30, 1899 to May 1, 2000)
longTemp = Fix( doc.Created ) 'check this number makes sense (see last line)!
'This is only for logging, testing.
Dim temp As String
temp = Format( doc.Created, "yyyy-mm-dd")+";"+doc.Noteid+";"
Call nStream.WriteText(temp,EOL_PLATFORM)
'******* Processing logic goes here **********
Set doc = nextDoc
Wend
Call nStream.Close()
Workaround 2: Filter through NotesDateTime?
Maybe this would work?
strFileName = "D:\temp\log.csv"
Set nStream = session.CreateStream()
nStream.Open(strFileName)
nStream.Truncate
Dim deleteCutoffDate As New NotesDateTime("Today")
Dim moveCutoffDate As New NotesDateTime("Today")
Dim createdDate As NotesDateTime '<----
Dim tmp As Integer
tmp = settingsDto.GetDeleteOlderThanMonths()
Call deleteCutoffDate.Adjustmonth((-1)*tmp, True)
Call deleteCutoffDate.SetAnyTime '<----
searchForm$ = {Form = "Memo" }
Set doccol = db.Search(searchForm, Nothing, 0) 'db is an opened NotesDatabase
Set doc = doccol.GetFirstDocument
While Not doc Is Nothing
Dim nextDoc As NotesDocument
Set nextDoc = doccol.Getnextdocument(doc)
'Earlier condition we tried
'If doc.Created < deleteCutOffDate.Lslocaltime
' deleteCutoffDate is today - 3 years
'Your current condition
'If (Fix( doc.Created ) < Fix( CDat(deleteCutoffDate.Dateonly))) Then
Set createdDate = New NotesDateTime(doc.Created) '<----
Call createdDate.SetAnyTime '<----
If createdDate.TimeDifference(deleteCutoffDate) < 0 Then '<----
'Suggested solution to check dates
Dim longTemp As Long
longTemp = Fix( CDat(deleteCutoffDate.Dateonly)) 'should be 36,647 (#days from Dec 30, 1899 to May 1, 2000)
longTemp = Fix( doc.Created ) 'check this number makes sense (see last line)!
'This is only for logging, testing.
Dim temp As String
temp = Format( doc.Created, "yyyy-mm-dd")+";"+doc.Noteid+";"
Call nStream.WriteText(temp,EOL_PLATFORM)
'******* Processing logic goes here **********
End If
Set doc = nextDoc
Wend
Call nStream.Close()
Workaround 3: Sanity filter
Add a function that checks and uses #Formulas if LotusScript fails, because while slower, hopefully that works
Function fdtSaneDocCreated(doc As NotesDocument) As Variant 'Dateonly
Const ciMinDate = 40179 'CLng(CDat("1/1/2010"))
Const ciMaxDate = 51136 'CLng(CDat("1/1/2040"))
fdtSaneDocCreated = doc.Created
If fdtSaneDocCreated < ciMinDate Or fdtSaneDocCreated > ciMaxDate Then
'This is slower, but AT LEAST IT WORKS! (... hopefully)
Dim array As Variant
array = Evaluate({#Created}, doc)
fdtSaneDocCreated = array(0)
If fdtSaneDocCreated < ciMinDate Or fdtSaneDocCreated > ciMaxDate Then
Error 1, "This workaround doesn't work for " + doc.NotesURL
End If
End If
End Function
and then change your code by replacing doc.Created with fdtSaneDocCreated(doc)

Sorry for the long silence I really needed to catch up with this project.
First of all thank you all for contributing to this thread all of your answers added a puzze piece to the picture.
So the problem was that the doc.Created reported wrong dates. Following your posts I red the following documentation.
http://www-01.ibm.com/support/docview.wss?uid=swg21111786
According to the link above a documents Created date is determined by the OID.
So there is this:
http://www-12.lotus.com/ldd/doc/domino_notes/9.0/api90ug.nsf/85255d56004d2bfd85255b1800631684/00d000c1005800c985255e0e00726863?OpenDocument
This link explains how the OID works and how it should look.
I checked the OID with NotesPeek and bingo! OID should have contained a vaild date but instead It was complete gibberish like 9856.06.20. Sometimes the date part was simply missing, that's why I saw 1899.
The closing point of this issue was the following link which confirmed that this strange behavior is a bug of Notes 8.5.1
https://www-01.ibm.com/support/docview.wss?uid=swg1LO47325

Related

Convert Dropdownlist String Value to Date

I want to do a date comparison to check whether is the Before Period is bigger than After Periode
So far it has been working properly until the date range is a bit tricky
For example
The value is from a dropdownlist item
Before period is 21-10-2022
After period is 04-11-2022
It will trigger the error message I set if the before period is bigger than the period after
I have a code like this
If CDate(ddlPeriodeBefore.SelectedValue) <= CDate(ddlPeriodeBefore.SelectedValue) Then
'Does the job if the the before period is smaller than after period
Else
lblInfo.Text = "Period BEFORE Must Be SMALLER Than Period AFTER."
End If
Can anyone help me? it keeps saying "conversion from string to date is not valid"
I've tried datetime.parse, parse exact, cdate, convert.todatetime but nothing works so far, or maybe I used it the wrong way
Please help, thanks in advance
Tim Schmelter's suggestion is not wrong, but I did want to provide an alternative. Create a collection of Tuple, add the dates (both formatted string and native value) to the collection, then bind the control to the list.
Here is the alternative:
Dim dates As New List(Of Tuple(Of String, DateTime))()
Dim today = DateTime.Today
For daysSubtract = 90 To 0 Step -1
Dim dateToAdd = today.AddDays(-daysSubtract)
dates.Add(New Tuple(Of String, DateTime)(dateToAdd.ToString("dd-MM-yyyy"), dateToAdd))
Next
ddlPeriodeBefore.ValueMember = "Item1"
ddlPeriodeBefore.DisplayMember = "Item2"
ddlPeriodeBefore.DataSource = dates
ddlPeriodeAfter.ValueMember = "Item1"
ddlPeriodeAfter.DisplayMember = "Item2"
ddlPeriodeAfter.DataSource = dates
Now when you go to get the selected value, you can use a simpler conversion since the stored object is already a DateTime:
Dim beforePeriod = DirectCast(ddlPeriodeBefore.SelectedValue, DateTime)
Dim afterPeriod = DirectCast(ddlPeriodeAfter.SelectedValue, DateTime)
If (beforePeriod <= afterPeriod) Then
' ...
Else
lblInfo.Text = "Period BEFORE Must Be SMALLER Than Period AFTER."
End If
The advantage to this approach is that you do not have to refactor your code if the date formatting changes.
If DateTime.Parse works depends on your curren culture because you don't pass any. For me this works fine (but for you not):
Dim selectedValue1 = "21-10-2022"
Dim selectedValue2 = "04-11-2022"
Dim beforePeriod = Date.Parse(selectedValue1)
Dim afterPeriod = Date.Parse(selectedValue2)
So either you know the correct culture that you have used when you have created this string, then you can pass this as second parameter to Date.Parse, or you use ParseExact:
Dim beforePeriod = Date.ParseExact(selectedValue1, "dd-MM-yyyy", CultureInfo.InvariantCulture)
Dim afterPeriod = Date.ParseExact(selectedValue2, "dd-MM-yyyy", CultureInfo.InvariantCulture)
The culture is relevant because they can have different date separators and the order of the day-, month- and year-tokens are different.

How to loop through XML-nodes and validate if values exists?

I have through an API fetched my data as an XML, and I wish to cycle through nodes (there are several of the same type) and add them to certain fields/a table.
Example from the XML-file:
<HistRating
xmlns="">
<EndrAr>2020</EndrAr>
<EndrMnd>7</EndrMnd>
<Rating>A</Rating>
</HistRating>
<HistRating
xmlns="">
<EndrAr>2019</EndrAr>
<EndrMnd>6</EndrMnd>
<Rating>A</Rating>
</HistRating>
I have tried the following format (at this point the XML I need is in a string in xmlDoc xmlDoc = CreateObject("MSXML2.DOMDocument.6.0"). Fully aware that this is not a really "sexy" way to write it, but I'm new at this game:
Set nodeXML = xmlDoc.getElementsByTagName("EndrAr")
Range("G1").Value = nodeXML(1).Text
Range("H1").Value = nodeXML(2).Text
Range("I1").Value = nodeXML(3).Text
Set nodeXML = xmlDoc.getElementsByTagName("EndrMnd")
Range("G2").Value = nodeXML(1).Text
Range("H2").Value = nodeXML(2).Text
Range("I2").Value = nodeXML(3).Text
Set nodeXML = xmlDoc.getElementsByTagName("Rating")
Range("G3").Value = nodeXML(1).Text
Range("H3").Value = nodeXML(2).Text
Range("I3").Value = nodeXML(3).Text
This works great as long as all three items are there. Unfortunately that is not given. If it is a new company i.e. (3) wont exist (there is one line per year above), and I would like to either set the cell to Blank or No value or something.
The result from when I run the above code:
But if I try to add a line 4 to test what happens if value does not exists I get the following (for obvious reasons)
What I would love some help with is:
Can I by some "magic" add a ifmissing (tried it, but could not get it to work)?
Other ways to add a if variable is not found, input following into cell
Or are there a complete different way I should have solved this?
This is to add accounting data from last X available years (where X is ie 4, or less if not 4 is available) from 30 nodes.
You could use an Error trapping Function. Note in the code below we choose not to use the returned boolean.
Dim myTest as String
.
.
TryReadingXmlNode nodeXML,1, myText
Range("G1").Value = myText
.
.
Public Function TryReadingXmlNode(ByVal ipNode as object, ByVal ipIndex as Long, ByRef opText as string) as boolean
On Error Resume Next
opText=ipNode.Item(ipIndex).Text
TryReadingXmlNode=Len(opText)>0
If err.number>0 then opText="NoValue"
on Error Goto 0
End Function
Start by querying all of the HistRating elements, then loop over that collection:
Const MAX_YEARS As Long = 4
Dim ratings, rating, c As Range, i as Long
Set c= Range("A1")
Set ratings = xmlDoc.getElementsByTagName("HistRating")
For Each rating in ratings
c.offset(0, i) = rating.getElementsByTagName("EndrAr")(0).Text
c.offset(1, i) = rating.getElementsByTagName("EndrMnd")(0).Text
c.offset(2, i) = rating.getElementsByTagName("Rating")(0).Text
i = i + 1
If i >= MAX_YEARS Then Exit For 'exit if processed enough nodes
Next rating

Lotus scripts Set value(Unique Number) in each document from GetAllDocumentsByKey

From my code below try to Looping from "GetAllDocumentbyKey" and Set Unique number each document for to show in Folder View , but from my code it's not work.
How should I solve this problem?
Dim defect As Variant
defect = uidoc.FieldGetText("DefectMode")
keys( 0 ) =defect
Dim PartNo As Variant
partNo = uidoc.FieldGetText("PartNo")
keys( 1 ) = partNo
Set view = db.GetView("EmbedView2" )
Set dc = view.GetAllDocumentsByKey(keys,False)
Call dc.PutAllInFolder("EmbedFolder")
Do Until dc Is Nothing
call uidoc.FieldSetText("UniqueNo","number") // this code I try to set unique number to each document by number that's I plan to increase 1 , I have to set in "UniqueNo" Fieled
Loop
OK... There is a big part missing from your code.
uidoc is the currently open document and if I guess right, it has an embedded view in it called "EmbedFolder". The documents you want to modify all belong to a special DefectMode and a special PartNo (that of the currently open document)
I doubt that what you want makes sense, but I don't wanna go into that.
To make your code work you need to cycle through the document collection and set each documents value separately. This would simply look like this:
Dim intNumber as Integer
Dim doc as NotesDocument
intNumber = 1
Set doc = dc.GetFirstDocument()
Do until doc is Nothing
Call doc.ReplaceItemValue( "UniqueNo" , intNumber )
Call doc.Save( True, True, True )
Set doc = dc.GetNextDocument( doc )
Wend

Lotus Notes - Export emails to plain text file

I am setting up a Lotus Notes account to accept emails from a client, and automatically save each email as a plain text file to be processed by another application.
So, I'm trying to create my very first Agent in Lotus to automatically export the emails to text.
Is there a standard, best practices way to do this?
I've created a LotusScript Agent that pretty much works. However, there is a bug - once the Body of the memo exceeds 32K characters, it starts inserting extra CR/LF pairs.
I am using Lotus Notes 7.0.3.
Here is my script:
Sub Initialize
On Error Goto ErrorCleanup
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim uniqueID As Variant
Dim curView As NotesView
Dim docCount As Integer
Dim notesInputFolder As String
Dim notesValidOutputFolder As String
Dim notesErrorOutputFolder As String
Dim outputFolder As String
Dim fileNum As Integer
Dim bodyRichText As NotesRichTextItem
Dim bodyUnformattedText As String
Dim subjectText As NotesItem
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
'INPUT OUTPUT LOCATIONS
outputFolder = "\\PASCRIA\CignaDFS\CUser1\Home\mikebec\MyDocuments\"
notesInputFolder = "IBEmails"
notesValidOutputFolder = "IBEmailsDone"
notesErrorOutputFolder="IBEmailsError"
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
Set db = session.CurrentDatabase
Set curview = db.GetView(notesInputFolder )
docCount = curview.EntryCount
Print "NUMBER OF DOCS " & docCount
fileNum = 1
While (docCount > 0)
'set current doc to
Set doc = curview.GetNthDocument(docCount)
Set bodyRichText = doc.GetFirstItem( "Body" )
bodyUnformattedText = bodyRichText.GetUnformattedText()
Set subjectText = doc.GetFirstItem("Subject")
If subjectText.Text = "LotusAgentTest" Then
uniqueID = Evaluate("#Unique")
Open "\\PASCRIA\CignaDFS\CUser1\Home\mikebec\MyDocuments\email_" & uniqueID(0) & ".txt" For Output As fileNum
Print #fileNum, "Subject:" & subjectText.Text
Print #fileNum, "Date:" & Now
Print #fileNum, bodyUnformattedText
Close fileNum
fileNum = fileNum + 1
Call doc.PutInFolder(notesValidOutputFolder)
Call doc.RemoveFromFolder(notesInputFolder)
End If
doccount = doccount-1
Wend
Exit Sub
ErrorCleanup:
Call sendErrorEmail(db,doc.GetItemValue("From")(0))
Call doc.PutInFolder(notesErrorOutputFolder)
Call doc.RemoveFromFolder(notesInputFolder)
End Sub
Update
Apparently the 32KB issue isn't consistent - so far, it's just one document that starts getting extra carriage returns after 32K.
With regards the 32Kb thing, instead of this:
Set bodyRichText = doc.GetFirstItem( "Body" )
... you might want to consider iterating all "Body" fields in the email document. When dealing with large amounts of rich text, Domino "chunks" said content into multiple rich text fields. Check some documents you're processing: you may well see multiple instances of the "Body" field when you look at document properties.
I'm not sure what is causing the 32K bug, but I know there are lots of limitations in the order of 32K or 64K within Lotus Notes, so perhaps you're running into one of those. I can't imagine what would add extra CR/LFs. Perhaps you could try using the GetFormattedText method on the NotesRichTextItem class and see if it fares better?
It's more complicated, but you might also be able to use the NotesRichTextNavigator class to iterate through all the paragraphs in the memo, outputting them one at a time. Breaking up the output that way might eliminate the CR/LF problem.
Lastly I always suggest Midas' LSX for dealing with rich text in Lotus Notes. They sell an add-on that gives you much more control over rich text fields.
As for best practices, one that comes to mind when I read your code is the looping construct. It is more efficient to get the first document in a view, process it, and then get the next doc and check whether it is equal to Nothing. That sets the loop to run through the view in index order, and eliminates the need to search through the index to find the Nth document each time. It also saves you from maintaining a counter. The gist is as follows:
Set doc = curview.GetFirstDocument()
While Not (doc Is Nothing)
'Do processing here...
Set doc = curview.GetNextDocument(doc)
Wend
The external eMail most likely comes in as MIME. So you could check the document.hasMime and then use the mime classes to get to the content. Then you don't have a 64k limit. Samples are in the help - or reply if you want code.

How do I Use a Date in an Array in GetAllEntriesByKey?

I'm trying to use the current day in GetAllEntriesByKey by passing an array. The array so far looks like this
Dim keyarray(2) As Variant
keyarray(0) = "FF Thompson ADT"
Set keyarray(1) = dateTime
I would like to say this
Set vc = view.GetAllEntriesByKey(keyarray, False)
Here is a row of what it looks like when it works. The test agent prints out csv in an email.
FF Thompson ADT,2/3/2009,11:45:02 PM,0,6,0,,00:00:04,5400,4
I can't seem to pass a current day dateTime that runs. I can set the dateTime manually in the declaration and it works. I think it's because it's trying to also pass the time but I don't know. I have tried three ways and it says invalid key value type.
Dim dateTime As New NotesDateTime("")
Call dateTime.LSLocalTime = Now
...
keyarray(1) = dateTime.Dateonly
Dim dateTime As New NotesDateTime("")
Call dateTime.SetNow
...
keyarray(1) = dateTime.Dateonly
Dim dateTime As New NotesDateTime("Today")
...
keyarray(1) = dateTime.Dateonly
I don't know if this is useful but I read about Evaluate here.
What I'm ultimately trying to do is GetFirstEntry for "FF Thompson ADT" for the most recent day entries exist. I'm also trying to do the same for the day before that. I'm trying to sum up the files processed (the number 6) for both days and errors (the null) for the most recent day using something like this. I need to tweak it so it finds the files processed and errors for entries but I haven't gotten there but should be able to do. I'm also just trying to find the most recent date with time value for the feed ie "FF Thompson ADT".
Set entry = vc.GetFirstEntry
filesprocessed = 0
Dim errors, errortotal As Integer
errors = 0
errorstotal = 0
While Not entry Is Nothing
rowval = 0
errors = 0
Forall colval In entry.ColumnValues
If rowval > 0 Then
errors = Cint(colval)
Else
rowval = Cint(colval)
End If
End Forall
filesprocessed = filesprocessed + rowval
errorstotal = errorstotal + errors
Set entry = vc.GetNextEntry(entry)
Wend
Thanks for any help or suggestions. They are greatly appreciated.
I've only used the GetAllEntriesByKey method with an array of strings. I've never tried mixing types. But assuming differing types are valid for that method, the problem might lie in the difference between datetime types in Notes. There's a core LS datetime type and then there's a NotesDateTime object. I'd bet the view considers a date column to be made up of the core datetime types, and so it fails when you pass the NotesDateTime type.
But that issue aside, my suggestion is to create a view that has the columns you want to access, and set the sort order of the first column (containing FF Thompson ADT) to asc, then set the second column with your dates to desc. You can then access the view entries in the order you want, with the most recent being first, 2nd most recent 2nd, etc.
If by some chance the GetAllEntriesByKey method returns the documents out of order (I forget if it guarantees order), I know I've done this before using the NotesViewNavigator class. There's definitely an alternate way to do it without need to call GetAllEntriesByKey with the date key.
Here's an answer I found
Dim todaysdate As New NotesDateTime("Today")
Dim dateTime As New NotesDateTime(todaysdate.DateOnly)
Dim keyarray(1) As Variant keyarray(0) = feedname
Set keyarray(1) = dateTime
Set vc = view.GetAllEntriesByKey(keyarray, False)

Resources