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