Friday, May 25, 2007

Australian date format with date field in notes view column

Have been working on a Domino based website today as the client reported that the date format of their promotions listings had changed to American date format. After playing with the date and time settings on the server, then on the field that contained the date I decided a workaround was needed so that regardless of these settings the date would display in Australian format regardless. So from no on if you are displaying a date in an embedded notes view's column, on the web, why not use this work around. Solution is to break each part of the date up and rebuild the date in the desired Australian format. The code below speaks for its self as is pretty simple. Now should the domino database ever move servers or date and time settings on the server change this will have no affect on the display of the date. Here is the simple notes formula language to use.

day := @If(@Length(@Text(@Day(specialweekend))) <= 1;"0"+@Text(@Day(specialweekend));@Text(@Day(specialweekend)));
month := @If(@Length(@Text(@Month(specialweekend))) <= 1;"0"+@Text(@Month(specialweekend));@Text(@Month(specialweekend)));
year := @Text(@Year(specialweekend));

day + "/" + month + "/" + year