Hi All, Can any one tell me how to change the date format using LotusScript? Its coming as mm /date/year format for today 5/6/2008 Instead I need it in date/month /year format
thanks in advance
Sheri
Hi All, Can any one tell me how to change the date format using LotusScript? Its coming as mm /date/year format for today 5/6/2008 Instead I need it in date/month /year format
thanks in advance
Sheri
Subject: to change the date format
Dates don’t have a format – today, for instance, is 39574 (that’s a number, representing the number of days since December 31, 1899). That will be displayed in whatever format is set in the computer’s regional settings by default. If you need the value to display differently, you can use the date format settings on a Date/Time field or in a view column. If you need to convert the text to a string for display, you can use the Format function in LotusScript. DO NOT store a date value as a formatted string (except in very special circumstances under your complete control) – remember that the conversion from date to text and back will use the local machine settings by default, so if you force “6/5/2008” on one mchine, another my interpret the value as June 5, not May 6.
Subject: RE: to change the date format
Set docdatetime= New NotesDateTime(ND_peopledoc.Yourfield(0)) docdate =docdatetime.DateOnly
If docdate <> "" Then
strDt = addZero(Month(docdate)) & addZero(Day(docdate)) & Year(docdate)
Msgbox strDt
Make addzero function
Function addZero(dt As String) As String
If Len(dt) <> 2 Then
dt = "0" + dt
End If
addZero = dt
End Function
Subject: RE: to change the date format
As Stan indicated:
Set docdatetime= New NotesDateTime(ND_peopledoc.Yourfield(0))
If your field is a “string” and ther person who created the document is using one regional setting format and another person runs that code with a different regional format, this code will generate an error or the wrong date.
For example, if somone enter “01/02/03” What is “01/02/03”? Feb 3rd, 2001; Jan 2nd, 2003; Feb 1st. 2003?
Without know the persons regional setting format or storing the value as a Date/Time your will have problems.
I always advise when testing an application, change your regional settings to make sure it still works.
(Another one I see people get burned on all the time is numbers as text. Guess what, the french use comma as a decimal marker. Watch you system crash when you enter 1,23)