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.

  1. 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
    

  2. Create new date on the document.
    Dim currentDate As NotesDateTime
    Set currentDate = New notesdatetime("")
    currentDate.setnow
    doc.ReplaceItemValue "datefield",currentDate
    

  3. 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
By using the sample code above, all your problems about dates will be solved.

MEMBER FEEDBACK TO THIS TIP

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.

Dig Deeper on Lotus Notes Domino Agents

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close