Return a valid date value from a date field in a document

// Notes XSP Document
doc.getDocument().getItemValueDateTimeArray("DueDate")[0].toJavaDate()

// NotesDocument
doc.getItemValueDateTimeArray("DueDate")[0].toJavaDate()





Most often we have a "notes document" data source and connect that to a field on the document using simple data binding or expression language, e.g doc.DueDate
Using SSJS it is easy to use doc.getItemValueString("Subject") to return a string value from the notes document

but what if the field in the document is a date field, then you do NOT want to return that field as a string, because then you loos the formatting options available.

Using this code you will get the first value in a date time field in the document and you will be able to set the display type to "Date/Time" in a computed value.

JavaScript (Server)
Thomas Adrian
December 7, 2011 1:55 PM
Rating
650

All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.



No comments yetLogin first to comment...