Strangest Behavior: Cdat(DateOnly): Type Mismatch?

On about 0.05% of our deploys, this code would produce a type mismatch at the print statement:

Dim auxdate As New NotesDateTime(“”)

auxdate.SetNow

Print “Cdat”, Cdat(auxdate.DateOnly)

So i have to replace it with:

Print “Datenumber”, Datenumber (Year(auxdate.LSLocalTime), Month(auxdate.LSLocalTime), Day(auxdate.LSLocalTime))

Any ideas?

Subject: I suspect that the DateOnly portion of the NDT is empty

Are there any similarities between the machines that the error occurs on? Specifically looking for information on Notes version, OS, OS Locale.

You could work around the error with this code

Dim auxdate As New NotesDateTime("")

If Cstr(auxdate.dateonly) <> "" Then

	Print "Cdat", Cdat(auxdate.DateOnly)

Else

	Print "Datenumber", Datenumber (Year(auxdate.LSLocalTime), Month(auxdate.LSLocalTime), Day(auxdate.LSLocalTime))

End If

Subject: No, is not empy: auxdate.SetNow

Sorry, while simplifying i forgot to add this code i have before the prints, so no, it is not empty. That is the strange part!

auxdate.SetNow

So, this:

On Error Goto zonaste



Dim mensaje As String



Dim auxdate As New NotesDateTime("")

auxdate.SetNow



Print "Datenumber", Datenumber (Year(auxdate.LSLocalTime), Month(auxdate.LSLocalTime), Day(auxdate.LSLocalTime))

mensaje = "TEST1 OK" +Chr(10)



Print "Cdat", Cdat(auxdate.DateOnly)

mensaje = mensaje + "TEST2 OK" +Chr(10)

finally:

Msgbox mensaje

Exit Sub

zonaste:

mensaje = mensaje + "ERROR"

Resume finally

would fail at the second print on some machines.