I have a multi-value date field in my application called ReserveDates and a view of documents categorised by:(@Today - ReserveDates) / 86400 which gives me a view showing the number of days that have passed since the date(s) in the field.
This view works fine ON ALL MY SERVERS. Today it’s October 9th 2006 and (for example) if a document has a value of 5/10/2006 I see 4 in the column and so on. No problem so far.
If I look at the documents using Document Properties in the client the ReserveDates field looks fine too i.e it shows something like this:
05/10/2006 00:00:00 GDT
05/10/2006 00:00:00 GDT
Again, this is working as expected on ALL my servers.
When things start to go wrong is when I run a LotusScript agent on these documents and examine the dates.
The code I am running is this (I have missed out some of the unimportant code to keep this brief)
Dim todayDateTime As New NotesDateTime(Today)
Set doc = collection.GetFirstDocument
While Not doc Is Nothing
Forall d In doc.ReserveDates
Msgbox d
Set rDate = New NotesDateTime(d)
Msgbox rDate.DateOnly
diff = todayDateTime.TimeDifference(rDate) / 86400
Msgbox diff
End Forall
Set doc = collection.GetNextDocument(doc)
Wend
On my Windows XP Test Server (Running R6.5) everthing is fine - I get the exact results I would expect i.e something like
09/10/2006 09:09:57 AMgr: Agent (‘Date Testing’ in ‘Test.nsf’) message box: 05/10/2006
09/10/2006 09:09:57 AMgr: Agent (‘Date Testing’ in ‘Test.nsf’) message box: 05/10/2006
09/10/2006 09:09:57 AMgr: Agent (‘Date Testing’ in ‘Test.nsf’) message box: 4
However, on my Production Server (Windows 2003, Running Notes R7), even though THE VIEW WORKS FINE (i.e shows 4 days in the categorised column), when the agent runs all the dates are showing in mm/dd/yy format e.g
09/10/2006 08:54:12 AM AMgr: Agent (‘Date Testing’ in ‘test.nsf’) message box: 10/5/2006
09/10/2006 08:54:12 AM AMgr: Agent (‘Date Testing’ in ‘test.nsf’) message box: 10/05/2006
09/10/2006 08:54:12 AM AMgr: Agent (‘Date Testing’ in ‘test.nsf’) message box: 123
So how come on the Production Server the view shows 4 days (correctly) and the LS Agent takes the date in m/d/y format and returns 123 ?
But what REALLY confuses me is how it handles a date of 28th September 2006. In my view, all is ok. It shows 11 days. In the LotusScript agent I get.
09/10/2006 08:54:12 AM AMgr: Agent (‘Date Testing’ in ‘test.nsf’) message box: 9/28/2006
09/10/2006 08:54:12 AM AMgr: Agent (‘Date Testing’ in ‘tests.nsf’) message box: 28/09/2006
09/10/2006 08:54:12 AM AMgr: Agent (‘Date Testing’ in ‘test.nsf’) message box: -18
So not only do I have a weird value of -18, it’s also output the date in two formats - d/m/y and m/d/y (unlike the other document which resulted in two m/d/y outputs).
On my test server the script runs fine and shows the correct values.
What’s happening here??? Am I being stupid amd missing something obvious ?
Richard