Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Define a fix date separator in LotusScript for Format function

Status
Not open for further replies.

preachie

Programmer
Dec 19, 2007
47
DE
Hi everybody,

it's quite a time ago I used LotusScript to develop some applications so I'm a bit out of training ;)

At the moment I'm wondering if it's possible to define a fix date separator so the date format will not use the date separator of the current locale settings of the operating system.

In detail, I retrieve a date field and modify the format with the format function like

Code:
d = Format(da, "mm/dd/yyyy")

If the current OS locale settings are set to English I get back a date in the format 01/23/2009
But in my case, the locale settings are set to German, so I get back 01.23.2009

What I want to achieve is, that regardless of the locale settings I'll get back 01/23/2009.

At the moment I implemented a workaround, checking for occurences of a "." and do a split by "." and rebuild the string from the array.

Code:
If(Instr(d, ".") > 0) Then
  dateArray = Split(d, ".")
  d = dateArray(0) + "/" + dateArray(1) + "/" + dateArray(2)
EndIf

But I hope there is a "better" solution for it, since there are also different possibilities for a date separator. Some locales uses a "-" as separator, so my work around wouldn't work.

So, is there a way to use the Format function and define a fix date separator which should be used?

Thanks a lot for any advices in advance!

Cheers
preachie

 
I think the idea is that you do not worry about displaying the date, just set the date field to Custom format and put the separator you want.

Pascal.


I've got nothing to hide, and I'd very much like to keep that away from prying eyes.
 
Thanks for your answer Pascal.

Unfortunately I'm not allowed to change the design of any forms or lists so I have to resolve this just with LotusScript.

Any other ideas?

Thanks!
preachie
 
Not possible. Technically, you have no control over how people choose their date format, thus it is impossible to fix a format that covers all possible combinations. That is why there is a custom format choice in the display properties of the date field.
If you do not have design access to the field in question, then no one can ask you to do the job and honestly expect you to find a solution in code when there is none.
Your only choice is to code a proper NotesDateTime object and let Notes handle the date issues like it is supposed to.

Pascal.


I've got nothing to hide, and I'd very much like to keep that away from prying eyes.
 
Ok, thanks for your help Pascal.
I will see how to resolve this the best way.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top