CDAT problem with date field

In the following portion of code, I am using CDat to convert a date field on the form (ReminderDate) to a date value to save in an automated appointment field (StartDate). The value of the ReminderDate field is “08/26/2008” with no time stamp. However, when the script exexcutes, it is storing 08/26/2008 12:00:00 AM EDT as the value of the Startdate field that is being populated on the calendar appointment. How can I get the date to populate correctly?

Thanks in advance

Dim Date1 As String

Dim Date2 As Variant	

Dim Princ As String

Set uidoc = ws.CurrentDocument	

Dim N As String

N = uidoc.FieldGetText("Notify1")

Princ = "CN=" & N & "/O=SMF"

Date1 = uidoc.FieldGetText("ReminderDate")

Date2 = Cdat(Date1)

Dim db As NotesDatabase  

REM {Send Appointment Reminder to User Listed in ORIG Field

Dim Session As New NotesSession	

Dim mdoc As NotesDocument	

Dim db2 As New NotesDatabase("" , "") 

Call db2.OpenMail

Set mdoc = db2.createdocument

mdoc.form = "Appointment"

mdoc.AppointmentType = "0"

Dim Tar As String

Tar = uidoc.FieldGetText("Target")

Dim Subj As String

Subj = "6 Mo Follow Up With - " + Tar

mdoc.subject = Subj

mdoc.Body = "Please contact your potential client "

mdoc.StartDate = Date2 (This is where my problem lies)

mdoc.EndDate = Date2

Subject: RE: CDAT problem with date field

  1. Use the NotesDateTime class. LotusScript date/time variants don’t make a distinction between “no time” and midnight on the date.2. ReminderDate should not be a text field. Never store a date in a text field because different workstation settings will store and interpret these differently.

  2. Once ReminderDate is a date/time field, see NotesItem.DateTimeValue property.

Subject: RE: CDAT problem with date field

Hi AndreYou are simply genious.

I was searching for the code past one day.

To update the datefield from the excel sheet.

I used Cdat, TimeZone was also coming.

If i use Format, data type text is coming.

I just saw your code DateTimeValue method.

It works fine., It gives me date data type .

Thanks Again

Subject: CDAT problem with date field

The short answer to your question is to look at the SetAnyTime method of the NotesDateTime class.

But the longer answer is that you could avoid the issue entirely if you worked more with the back end classes. Using the ui classes, you are forced to convert the date to text, then back to a datetime. If you go directly from document to document, no conversion is necessary. I believe this statement would handle what you need:

mdoc.StartDate = uidoc.Document.ReminderDate

alternatively, you could first create an object for the backend of the current document:

currdoc = uidoc.document

mdoc.StartDate = currdoc.ReminderDate