Ask the Expert

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

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: