Wrong date using dateNumber with notesDateTime

Hi all,

I use the function DateNumber ( year , month , day ) inside a new NotesDateTime( dateTime$ ) object like this :

set tmp = new notesDateTime(DateNumber ( 2007 , 3 , 5 ))

The help doc states that dateTime$ should be a string while dateNumber function returns a Variant of DateType 7 (Date/Time)

In the case of my example, the month and day are inverted for the date stored in the notesItem.dateTimeValue, with the server date format set as MDY. The result is 05-03-2007 instead of 03-05-2007.

This issue does not apply when the day is larger then 12, like 03-13-2007, because the day cannot be interpreted as a month.

I found a workaround by using the three notesInternational property isDateYMD, isDateDMY and isDateMDY like this :

If i.IsDateDMY Then

  Set adaptedDate = New NotesDateTime(sDay + i.DateSep + sMonth + i.DateSep + sYear  )

Elseif i.IsDateMDY Then

  Set adaptedDate = New NotesDateTime(sMonth + i.DateSep + sDay + i.DateSep + sYear  )

Elseif i.IsDateYMD Then

  Set adaptedDate = New NotesDateTime(sYear + i.DateSep + sMonth + i.DateSep + sDay  )

End If

I have concerns regarding the following statement in the Designer 7 help for NotesDateTime object :

«The LotusScript functions DateNumber and TimeNumber can be used to avoid dependencies on regional settings. For example, the sum of DateNumber and TimeNumber can be written to GMTTime or LocalTime to set a NotesDateTime object.»

Bye

Subject: Wrong date using dateNumber with notesDateTime

The properties LSLocalTime and LSGMTTime can be used with DateNumber() and TimeNumber() because they have a variant data type. The example below is direct from the help.

Dim dateTime As New NotesDateTime( “” )

dateTime.LSLocalTime = Datenumber( 1997, 8, 18 )

I agree with you that the statement you quoted is wrong (if it refers to GMTTime or LocalTime) because these are string properties.

Using the syntax above instead of your workaround.

HTH, Rob