DateTime problem solved in agents
How to solve problems with dateTime in LotusScript agents running on the server with different dateTime settings.
View member feedback to this tip.
Problems with different dateTimes can be solved by using code below.
- Copy field from one document to another document.
If(doc1.HasItem("datefield")) Then If(Isdate(doc1.datefield(0))) Then doc2.datefield = doc1.datefield End If End If
- Create new date on the document.
Dim currentDate As NotesDateTime Set currentDate = New notesdatetime("") currentDate.setnow doc.ReplaceItemValue "datefield",currentDate
- Adjust the days of a datefield.
If (Isnumeric(doc.numberfield(0))) Then Dim iDate As notesdateTime If(Isdate(doc.datefield(0))) Then Set iDate = doc.getFirstItem("datefield"). dateTimeValue or(R6) Set iDate = doc.GetItemValueDateTimeArray("datefield")(0) iDate.AdjustDay(doc.getItemValue ("numberfield")(0)) If Not (doc.hasitem("otherdatefield")) Then doc.replaceItemValue
"otherdatefield", iDate end if end if
Good one. Much of the date time functionality can be solved by using the NotesDateTime class provided. It has lots of methods to adjust date and time by the parameter you specify and also date conversion functions like convertoZone to convert it different format.
You can use this method in agents written in the Webqueryopen portion of the form.
-- Kiran
Do you have comments on this tip? Let us know.