Are you creating databases that live on servers all around the world and worried that you don't know which format the server expects dates to be entered in to fields of the date/time data type?
You can use this method to be sure that dates get validated to the correct format, mm/dd/yyyy or dd/mm/yyyy depending on the settings of the server you are using.
First thing to do is find out which format the server uses. We can do this with a simple @Formula like the one below:
DateText:=@Text(@Date(2000; 12; 31); "D0S0");
Replace := "31" : "12" : "2000";
With := "dd" : "mm" : "yyyy";
@ReplaceSubstring(DateText; Replace; With)
This creates a reference to my New Year's Eve, year 2000, in text format and then replaces the day with dd, the month with mm and the year with yyyy. It can do this as it knows that where the 31 appears in the date string is the day part and the where the 12 appears is the month. The trick is that, with domino, this formula is computed on the server so the format is independent of the client's location.
The best way to use this code is to place it in a "hidden" computed for display text field called DateFormat that is on all your forms. JavaScript can then get the value of this whenever it needs to validate a date field.
Notice in the technique used above the HTML for the field is generated explicitly*.
We now have a dynamic value on every form accessible to JavaScript. On this site (hosted in America) the code generated is:
Copyright © 2000 - 2024 Jake Howlett of Rockall Design ltd. This article was printed from codestore.net