« LotusphereLive 2009 - Live Blogging | Main| Sherpa software adds IM archiving to it's product portfolio »

Getting an ISO8601 formatted Date using Domino @Formula

Category

I recently had a need to show a domino view column in ISO 8601 date/time format.  I was really hoping that as Notes uses this format in many of it's representations in Notes XML views that there would be something like a simple @TEXT option, sadly there isn't.  I wouldn't recommend using this in a view column directly, put a computed text field in your document that stores it, and refer to that in your view column.

So here's the formula that will return a date in UTC (zulu) time, assuming I want to use the Created date for the document

TimetoConvert := @Created;
DocTime := @TIMEMERGE(TimetoConvert ;TimetoConvert ;"Z=0$DO=1$DL=3 -1 1 10 -1 1$ZX=36$ZN=GMT");
Year:=  @Text (@Year(DocTime));
Month := @If(@Month(DocTime) < 10;"0";"") + @Text(@Month(DocTime));
Day := @If(@Day(DocTime) < 10;"0";"") + @Text(@Day(DocTime));
Hours := @If(@Hour(DocTime) < 10;"0";"") + @Text(@Hour(DocTime));
Minutes := @If(@Minute(DocTime) < 10;"0";"") + @Text(@Minute(DocTime));
Seconds := @If(@Second(DocTime) < 10;"0";"") + @Text(@Second(DocTime));

Year + "-" + Month + "-" + Day +"T" +Hours + ":" + Minutes + ":" + Seconds + "Z"


If you're wondering what "Z=0$DO=1$DL=3 -1 1 10 -1 1$ZX=36$ZN=GMT" actually means, it's basically the Domino Time Zone code for GMT with no Daylight savings, aka Universal Time(zulu time).  Anyway you'll have to continue to wonder what the format means exactly, to quote one of the best lines in an IBM support document ever.
he third parameter of the method contains a lengthy text string which represents the relative time zone (for example the string for Easter Daylight Time is "Z=5$DO=1$DL=4 1 1 10 -1 1$ZX=25$ZN=Eastern"). There is no documentation on these parameters, and in order to determine the correct string for the time zone you would like to use it is suggested that you create a sample form with a field with the type 'Timezone'.


How about someone documents the parameters? It must be on an internal IBM spec that defined this function when they wrote it, surely someone could document it for the public?

I hear Domino 8.5 is much better at this with XPages, but I can't run my server on Domino 8.5 until a supported Sametime version is shipped.

Comments

Gravatar Image1 - nothing crisps the mind like a little reverse engineering - nice job !

Gravatar Image2 - The most frequent need for an ISO8601 date/time is if you intend to put date values in a META tag for indexing by Google. The Google Search Appliance now allows for searching documents by the document's own date, rather than just by the date Google last indexed it, and all it accepts are ISO8601 values.

Gravatar Image3 - How about this then:
{ Link }

Gravatar Image4 - @3 Well I guess somebody needs to update that support document that says it isn't documented then.

Good to see someone had the foresight to post it.

Thanks James!

Gravatar Image5 - You should post this to the CodeBin on OpenNTF

Gravatar Image6 - Thanks for your information.

Post A Comment

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::rolleyes:;-)