Lotusscript日期时间问题

时间:2010-09-21 20:20:38

标签: datetime lotusscript

我在视图中存储了几个日期。我正在使用getItemValue来检索它们。

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

当我尝试执行以下操作时,我在运行时遇到类型错配。

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

有没有人对出了什么问题有任何想法?

2 个答案:

答案 0 :(得分:1)

以下行返回一个数组:

Set repsondedDate = timePart1doc.GetItemValue("dateResponded")

所以它应该是:

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

如果我没弄错,你应该使用GetItemValueDateTimeArray方法而不是GetItemValue,所以它应该是这样的:

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

希望有所帮助

答案 1 :(得分:0)

使用GetItemValueDateTimeArray代替,例如下面的IBM example

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