Notesdatetime type mismatch

Dim dtDoj As NotesDateTimedim ndocforDOJ As NotesDocument

'dtDOJ is datetime field

Set dtDoj = New NotesDateTime(ndocforDOJ.dtDOJ(0))

Msgbox “Date=>” & dtDoj.DateOnly 'No error

Msgbox “” & Cstr(Month(dtDoj.DateOnly))'type misnatch error

Msgbox “” & Cstr(Year(dtDoj.DateOnly))'type misnatch error

Subject: Notesdatetime type mismatch

The DateOnly property returns a String, note a Date. You can’t take the Month of a String.

Subject: RE: Notesdatetime type mismatch

Dim dtDoj As NotesDateTimedim ndocforDOJ As NotesDocument

'dtDOJ is datetime field

Set dtDoj = New NotesDateTime(ndocforDOJ.dtDOJ(0))

Msgbox “Date=>” & dtDoj.DateOnly 'No error

Msgbox “” & Cstr(Month(cdat(dtDoj.DateOnly)))’ type mismatch error

Msgbox “” & Cstr(Year(cdat(dtDoj.DateOnly)))’ type mismatch error

Still giving same problem … any other way of getting month of date

Since dtDoj is datetime field

Month(ndocforDOJ.dtDOJ(0)) is working fine , but want to know the reason why it is not working with notesdatetime

Subject: RE: Notesdatetime type mismatch

Why all the casting? There’s a method to get a Date variant from a NotesDateTime object – LSLocalTime. If you want to force the NotesDateTime object to a date-only (no time) value, use the SetAnyTime method.