Search This Blog

Wednesday, November 4, 2009

Format Sharepoint DateTime

A quick tips to formatting DateTime in XSLT for Content Qury Webpart through Editing Sharepoint ItemStyle or manually configure Dataview Webpart.

To achieve the desire format, there are string variable needed. (LCID & FormatFlag

LCID code is the localize language used by the hosting machine. Full listing of LCID code could be found Here. For illustration purpose, English-United State (1033) is used in following example. 

FormatFlag is the format apply to the date and time itself. FormatFlag can be apply using number or string format. A sample of numbering FormatFlag of en-US is available in the image below(Source). Full listing of FormatFlag for each language Here.

y1pvXScwycRj8VxEvHnvzscNrP8dWbGir_SV9on3kytIB4-3DSO1yoEMh4bJzAvWbjKNiC7pTF0By4[1] 

As for the text format a full list of FormatFlag can be found Here.

Example:

Numbering FormatFlag
ddwrt:FormatDate(string(@EventDate), 1033, 5)
= 5/9/2007 12:00 AM
 
String FormatFlag
ddwrt:FormatDate(string(@EventDate), 1033, d/m/yyyy)
=5/9/2007
 
ddwrt:FormatDate(string(@EventDate), 1033, dd/m/yyyy)
=05/9/2007
 
ddwrt:FormatDate(string(@EventDate), 1033, dd/mmm/yyyy)
=05/Sep/2007

Other useful resources:

No comments:

Post a Comment