Why does my calendar shift events by a day?

I have a calendar view that shows events entered into a database. There is a button on the view that shows two days -- using code @Command([CalendarFormat]; "2"). When the above button is clicked, the calendar view shows tomorrow's events on today's day and moves everything back one day. Any ideas?
I believe this problem is caused by a LotusScript programming error in the code that assigns the date fields in the documents.

The problem occurs when you assign a date field from a LotusScript date/time variant, using a statement such as:

apptDate = Datenumber(2002, 12, 13)
doc.CalDate = apptDate
or even
doc.CalDate = otherDoc.CalDate
The LotusScript date/time variant doesn't have a distinct representation for a date with no time -- it considers that the same as midnight on the given date, in the time zone of the computer running the script. As a result, if the user's workstation is in an earlier time zone than that computer, the entry would appear on the previous day's calendar page, because 12:00 a.m. in Boston, for example, is 11:00 p.m. on the previous day in Minneapolis.

To prevent this problem, always use the NotesDateTime class when working with date fields. In the above example:

Dim fldCalDate As NotesItem
Dim datCalDate As NotesDateTime
Set fldCalDate = otherDoc.GetFirstItem("CalDate")
Set datCalDate = fldCalDate.DateTimeValue
datCalDate.SetAnyTime ' in case there's a time value in the field we're copying, remove it.
Set doc.CalDate = datCalDate

This was first published in June 2003