Here is a sample code:
Dim dt As New NotesDateTime(“”)
dt.LSLocalTime = Datenumber(2009, 07, 31)
Call dt.AdjustMonth (-1)
Msgbox Cstr(dt.LSLocalTime)
The same simple cut of script works completely different in notes 6.5.3 and notes 8.0.2, 8.5
Notes6 returns “6/30/2009”. But!! Notes8 returns “7/01/2009”. Obviously r8 returns not a prev month but just the same month as it was set initially by LSLocalTime.
Moreover let’s change code a bit and exclude LSLocalTime calling:
Dim dt As New NotesDateTime(“7/31/2009”)
Call dt.AdjustMonth (-1)
Msgbox Cstr(dt.LSLocalTime)
Now it works properly in both r6 and r8.
Next possible solution is to call SetAnyTime method right after setting LSLocalTime. It also says “6/30/2009” in both r6 and r8.
Local time zone tested was GMT+2.
ps: We’ve just tested with our colleagues and seems like the issue is coming from early Notes7
Subject: I think you are crossing midnight
Haven’t tested it, but you are creating the DateTime object at midnight, so when you look at LocalTime, you are one day later (GMT+2). For a simple test, try a date not EOM. Or seed the time at something well before midnight.
Subject: issue could be reproduced anytime. there is no any midnight dependence
Subject: well, maybe you’re wrong!
Add one line, to move the time away from midnight, and it works!
Dim dt As New NotesDateTime(“”)
dt.LSLocalTime = Datenumber(2009, 07, 31)
Call dt.AdjustHour (+10)
Call dt.AdjustMonth (-1)
Msgbox Cstr(dt.LSLocalTime)
Subject: The main question is … (+)
The main question is that there were tons of application which worked for an ages in R6 but now on R8 that same code crashes every 31th of the month.
I personally know lots of workarounds like yours to add hours or something like that.
But in our particular case we are setting a date without any time part at all using DateNumber function and we assume that it should set a date without a time.
It was just perfect in R6 and worked years and years.
But now migrating to R8 we’ve found that simple logic described in official designer help just stopped working.
We assume that saing AdjustMonth the script should adjust just a month without anything like bla-bla-bla-crossing-midnight, we need just month adjusted and nothing more.
Does it clear?
Subject: if you use the right code in the first place…
Dim dt As New NotesDateTime(“”)dt.LocalTime= Datenumber(2009, 07, 31)
Call dt.AdjustMonth (-1)
Msgbox Cstr(dt.LSLocalTime)