Sunday, July 17, 2011

SharePoint 2010 CQWP date format

Sometimes we need to customize the style of SharePoint Content Query Web Part (CQWP). If we need to change the datetime column display format, here are general steps we can do:



1. Open your top-level site in Sharepoint Designer, click “All Files – Style Library – XSL Style Sheets – ItemStyle.xsl”
 

2. Please add following reference right below the “xmlns:cmswrt” (usually line 6)

xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"



3. Then we can add xsl variable to save the converted result like below

<xsl:variable name="Created"> <xsl:value-of select="ddwrt:FormatDateTime(string(@Created) ,1033 ,'dd.MM.yyyy')" /></xsl:variable>



Here is more information about  ddwrt:FormatDateTime:


List of supported locale identifiers in Word



Custom Date and Time Format Strings



SharePoint Data View Web Part Extension Functions in the ddwrt Namespace

No comments:

Post a Comment