Hi people,
I have searched the forum but nothing which can answer my problem specifically.
The problem lies with then function “Today” in lotuscript, or the New function for notesDateTime.
I am breaking the variant down to create a customised string, and the results are correct for me when i tested. But for another user, the day and month is reversed, hence a wrong result.
I changed the date format in my windows to test, but realised that the result i got is still correct. even though the day and month is reversed, the notesDateTime item is still able to get the correct format. so What is causing this problem with this specific user?
Is there a way to ensure the code is correct for users of different settings?
datefield = Today
Dim expiry As New NotesDateTime(Today)
Call expiry.AdjustMonth(4)
Dim vDate As Variant
vDate = expiry.LSLocalTime
Dim yr As Variant, mth As Variant, dd As Variant
yr = Year(vDate)
yr = Right(yr, 1)
mth = Month(vDate)
If mth < 10 Then
mth = "0" & mth
End If
dd = Day(vDate)
If dd < 10 Then
dd = "0" & dd
End If
for me, if today is 12th Dec 2005, the result will be 12th April 2006.
But for the user, he got 16th Dec 2005
please help. Thanks in advance.
Subject: date Format, yes, again
These two different ways should do it (as far as I am aware):
Dim ndt As New NotesDateTime( Today )
Dim strDate As String
Dim varDate As Variant
Call ndt.AdjustMonth( 4 )
’ // Method ONE…look at Format in the help file, there is a load of other stuff you can do with it.
strDate = Format( ndt.DateOnly, “dd-mmm-yyyy”)
Msgbox strDate
’ // Method TWO…get Date variant, then pull the year, month, day bit out (should be the same regardless of the OS), then format it however you want.
varDate = Cdat( ndt.DateOnly )
strDate = Cstr( Day( varDate ) ) + {-} + Cstr( Month( varDate ) ) + {-} + Cstr( Year( varDate ) )
Msgbox strDate
Subject: RE: date Format, yes, again
Yeah – there’s got to be something fundamentally screwy with the settings on the computer that’s throwing errors if Today is causing a problem. The direct assignment to a date variant should never fail, but using Today (the function) instead of “Today” (the string) in the NotesDateTime constructor could conceivably cause a problem – first, Today is evaluated to a date variant, then that is Cstr’ed before being fed to the NotesDateTime constructor. Please note that I am NOT saying that it is a likely source of problems, but without knowing the source code for the LS engine inside-out, it is sorta kinda vaguely possible that the date-format info may be sourced from different areas in different calls, and it IS possible to have, say, a local date-time format setting that is at odds with the locale settings. That’s the only way I can see the input to the NotesDateTime reversing the month and day.
Subject: RE: date Format, yes, again
Hey thanks Nick and Stan for the response.
I have sorta drawn a conclusion the fault lies in the New function for NotesDateTime.
In the same function:
Doc.finaldate = Today
is called and there are no errors for this.
And I have tried:
set vDate = New NotesDateTime(Format$(Today,“General Date”))
which gave the same wrong result from this user.
Now using:
set vDate = New NotesDateTime(“Today”)
and praying it works. I have tried all possible date format settings in Win XP in my on comp and there are no problems.
Any feedback will be great.