Manage Learn to apply best practices and optimize your operations.

Set date without time via LotusScript

This tip shows you how to set the date without the time section via LotusScript.

Most methods for setting a date field via LotusScript leave you with a date in this format:

13/07/2014 00:00:00 GDT

The time section always seems to get set either to the current time or 00:00:00.

If the date is required to be stored in the same format as it would be if chosen from the date picker on a form, the time part must be removed.

The LotusScript functions, CDat, DateNumber, DateValue, Format are no help here, nor is the notesddatetime object -- unless you do what I have done in the following function.

The function takes a document, a fieldname and a date and sets the field equal to the date only value of the date, without the time part.

Code:

Function SetDate(doc As notesdocument, 
strFieldName As String, strDate As 
String) 'Takes a Date and puts it in a 
field without any time part nonsense and 
as a proper date not a string.
 Dim dtmTemp As New notesdatetime ("")
 dtmTemp.LSLocalTime = Datevalue(strDate)
 Call dtmTemp.setAnyTime
 doc.ReplaceItemValue strFieldName, 
dtmTemp End Function

Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip exchange by member Brendan Dougan. Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.

Dig Deeper on LotusScript

SearchWindowsServer

Search400

  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/Search400.com community. These cheat ...

  • HTML cheat sheet

    This is a really cool cheat sheet if you're looking to learn more about HTML. You'll find just about everything you every wanted ...

  • Carol Woodbury: Security

    Carol Woodbury

SearchDataCenter

SearchContentManagement

Close