< Back

Document Subject: Convert a Notes Date Field to NotesDateTime and to LotusScript variant of type Date
Hint Short Cut: Add this to your code & documentation to help you find this page.
http://#DateConversion or http://A555F9/nn.nsf/ByAlias/DateConversion

Converting from Date fields to LotusScript Date type variants can be tricky. Here is a short summary.




 

'this code uses a document date field to create a long date format

'if the date field is not present or badly formed the document.created property is used

             dim niPubDate as notesitem

             dim ndt as notesdatetime

             dim lslocaltime as variant


            Set niPubDate = doc.getfirstitem("DocCreated")
            If Not(niPubDate Is Nothing) Then
                  Set ndt = niPubDate.datetimevalue

                   If ndt Is Nothing Then
                        lslocaltime = doc.created
                  Else
                        lsLocalTime =ndt.lslocaltime
                  End If
            Else
                  'use default doc.created
                  lslocaltime = doc.created
            End If

             Print "RSS type date:" &   dow(Weekday(lsLocalTime)) & ", " & Day(lsLocalTime) & " " & _
            mon(Month(lsLocalTime)) & " " & Right(Cstr(Year(lsLocalTime)),2) & _
            " " & Right("0" & Hour(lsLocalTime),2) & ":" & Right("0" & Minute(lsLocalTime),2)  & _
            ":" & Right("0" & Second(lsLocalTime),2) & " GMT"