Kris.Mitchell
Kris.Mitchell

Reputation: 998

Lotusscript date time issues

I have a couple of dates stored in a view. And I am using getItemValue to retrieve them.

Dim repsondedDate As NotesDateTime
Set repsondedDate = timePart1doc.GetItemValue("dateResponded")

When I try to do the following, I get a type missmatch at run time.

Dim dateDifference As double
Set dtLocal = New NotesDateTime( Now )
dateDifference = repsondedDate.Timedifference(dtLocal)

Does anyone have any ideas on what is going wrong?

Upvotes: 1

Views: 2063

Answers (2)

Michael Fayad
Michael Fayad

Reputation: 1336

Use GetItemValueDateTimeArray instead like the IBM example below:

Sub Initialize
  Dim session As New NotesSession
  Dim db As NotesDatabase
  Dim dc As NotesDocumentCollection
  Dim doc As NotesDocument
  Dim count As Integer
  Set db = session.CurrentDatabase
  Set dc = db.UnprocessedDocuments
  If dc.Count = 0 Then Exit Sub
  Set doc = dc.GetFirstDocument
  Dim times As Variant
  times = doc.GetItemValueDateTimeArray("Times")
  count = 0
  Forall t In times
    count = count + 1
    If Typename(t) = "NOTESDATETIME" Then
      Messagebox t.LocalTime,, "Date/time # " & count
    Elseif Typename(t) = "NOTESDATERANGE" Then
      Messagebox t.StartDateTime.LocalTime & " - " & _
      t.EndDateTime.LocalTime,, "Date/time # " & count
    End If
  End Forall
End Sub

Upvotes: 0

Carlos
Carlos

Reputation: 1806

The following line returns an array:

Set repsondedDate = timePart1doc.GetItemValue("dateResponded")

So it should be:

Set repsondedDate = timePart1doc.GetItemValue("dateResponded")(0)

If I'm not mistaken you should be using the GetItemValueDateTimeArray method instead of the GetItemValue, so it should actually be like this:

Set repsondedDate = timePart1doc.GetItemValueDateTimeArray("dateResponded")(0)

Hope that helps

Upvotes: 2

Related Questions