Examples: NotesDateTime class

  1. This agent creates a NotesDateTime object that represents 4 March 2005 at 6:07:08 AM. The use of DateNumber and TimeNumber eliminates dependencies on regional settings.
    Sub Initialize
      Dim dateTime As New NotesDateTime("")
      dateTime.LocalTime = Datenumber(2005, 03, 04) + Timenumber(6, 7, 8)
      Messagebox dateTime.LocalTime,, "Local time"
    End Sub
  2. This agent creates a NotesDateTime object that represents 4 March 2005 at 6:07:08 if the regional setting is appropriate, for example, M/d/yy h:mm:ss. When you set the date from a String, you must be sure that the regional settings of the user's computer are appropriate to the String value.
    Sub Initialize
      Dim session As New NotesSession
      If session.International.IsDateMDY And _
      session.International.DateSep = "/" And _
      session.International.TimeSep = ":" Then
        Dim dt As New NotesDateTime("3/4/05 6:07:08")
        Messagebox dt.LocalTime,, "Local time"
      Else
        Messagebox "Not MDY with / and :",, "Date format not appropriate"
      End If
    End Sub
  3. This agent creates a new DateTime object that represents today's date. The time component of the DateTime object is not set.
    Sub Initialize
      Dim dt As New NotesDateTime("Today")
      Messagebox dt.LocalTime,, "Local time"
    End Sub
  4. This agent creates a new DateTime object that represents the current date and time.
    Sub Initialize
      Dim dt As New NotesDateTime("Today")
      Call dt.SetNow
      Messagebox dt.LocalTime,, "Local time"
    End Sub
  5. This agent gets the value of the PurgeDate item in a document and places it into a NotesDateTime object. The time zone setting of PurgeDate is preserved. For example, if PurgeDate has a value of 03/21/96 04:54:33 PM in Eastern Standard Time, the DateTime object represents 03/21/96 04:54:33 PM and its TimeZone property equals 5.
    Sub Initialize
      Dim session As New NotesSession
      Dim doc As NotesDocument
      Dim item As NotesItem
      Dim dt As NotesDateTime
      Set doc = session.DocumentContext
      Set item = doc.GetFirstItem("PurgeDate")
      Set dt = item.DateTimeValue
      Messagebox dt.LocalTime & " TZ" & dt.TimeZone,, "Local time"
    End Sub