'Example code:
Dim months(12) As String
months(1)="Jan"
months(2)="Feb"
months(3)="Mar"
months(4)="Apr"
months(5)="May"
months(6)="Jun"
months(7)="Jul"
months(8)="Aug"
months(9)="Sep"
months(10)="Oct"
months(11)="Nov"
months(12)="Dec"
Set WarningTimeDate = New notesdatetime(Today)
WarningTimeDate.setnow
Call rt.appendtext("NB Checking" & warningdays & " days ahead. " & Day(warningtimedate.dateonly) & "-" & months(Month(warningtimedate.dateonly)) & "-" & Year(warningtimedate.dateonly) )
Call rt.addnewline(1)
' See http://www.notesninjas.com/#ServersMMDD for info on this code
Dim lstime As Variant
lstime = warningTimedate.LSLocalTime
Call rt.appendtext("LSTIME NB Checking" & warningdays & " days ahead. " & Day(lstime) & "-" & months(Month(lstime)) & "-" & Year(lstime) )
Call rt.addnewline(1)
Running on a client that is dd/mm/yyyy the richtext item returns:
NB Checking 52 days ahead. 1-Jun-2002
LSTIME NB Checking 52 days ahead. 1-Jun-2002
Running on a server that is mm/dd/yyyy the richtext item returns:
NB Checking52 days ahead. 6-Jan-2002
LSTIME NB Checking52 days ahead. 1-Jun-2002
So use the green code above to make sure it will work.
AF Update 10th May 2006 (or 5th October 2006) I have revisted this problem:
Company decided to change the server dates to mdy instead of dmy. :(
I store the the last run time of the agent as a string in a keyword document so that humans as well as the agent can change it.
NB I did consider using notesagent.lastrun as the way of storing the last date, but this would be reset when the agent is resaved etc and cannot be set to an arbitrary date as it is read only.
anyway: I used these functions to switch the dates around:
Function ChangeFromDateFormat(Byval dateval As Variant) As String
' this code changes the uk date format string to the current server/client's date format string
'agreed date format is:
' dd/mm/yyyy hh:mm:ss PM TTT
' eg 05/10/2006 02:33:17 PM ZE2
Dim s As New notessession
Dim nint As NotesInternational
Set nint=s.International
If Cstr(dateval)="" Then
ChangeFromDateFormat=""
Exit Function
End If
If nint.DateSep <> "/" Then
'change date separator
datesep=replacesubstring(datesep,"/",nint.DateSep)
End If
'is not dmy
If nint.IsDateDMY Then
'cool nothing to do
Elseif nint.IsDateMDY Then
'swop over days and months
dateval = Mid$(dateval,4,2) & nint.DateSep & Mid$(dateval,1,2) & Mid$(dateval,6,20)
Elseif nint.IsDateYMD Then
'swop over yearsmonths and days !
dateval = Mid$(dateval,7,4) & nint.DateSep & Mid$(dateval,4,2) & nint.DateSep & Mid$(dateval,1,2) & Mid$(dateval,11,20)
End If
ChangeFromDateFormat = dateval
Goto FinishOff
ErrHdlr:
ChangeFromDateFormat="Error " & Error$ & " at line " & Erl
FinishOff:
End Function
and this one:
Function ChangeToDateFormat(Byval dateval As Variant) As String
' this code changes the datse string to the uk date format string
'agreed date format is:
' dd/mm/yyyy hh:mm:ss PM TTT
' eg 05/10/2006 02:33:17 PM ZE2
Dim s As New notessession
Dim nint As NotesInternational
Set nint=s.International
If Cstr(dateval)="" Then
ChangeToDateFormat=""
Exit Function
End If
If nint.DateSep <> "/" Then
'change date separator
datesep=replacesubstring(datesep,nint.DateSep,"/")
End If
'is not dmy
If nint.IsDateDMY Then
'cool nothing to do
Elseif nint.IsDateMDY Then
'swop over days and months
dateval = Mid$(dateval,4,2) & "/" & Mid$(dateval,1,2) & Mid$(dateval,6,20)
Elseif nint.IsDateYMD Then
'swop over yearsmonths and days !
dateval = Mid$(dateval,9,2) & "/" & Mid$(dateval,6,2) & "/" & Mid$(dateval,1,4) & Mid$(dateval,11,20)
End If
ChangeToDateFormat=dateval
Goto FinishOff
ErrHdlr:
ChangeToDateFormat="Error " & Error$ & " at line " & Erl
FinishOff:
End Function
These allow the stored in keyword date to always be in dmy and the server agent can translate it to it's only crappy format mdy or dmy if it is actually configured ok or even YMD (not tested).
NB At lotusphere 2006 someone asked a guru about this and he replied: "Windoze is designed to run in America. MS are not that bothered about it running properly anywhere else. The solution is to install Linux and run Notes Server from there. :) "