Sep.07

How to format date in SharePoint XSL templates?

In many projects when using CQWP web parts you need to customize date format. By default, SharePoint gives date with time, but we often need only date. Here is a simple scenario:

  1. First you need to reference the ddwrt namespace at the top of your <xsl:stylesheet> tag:
    xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime
  2. In order to display custom date format you have to use the following code (replace @ArticleStartDate with your column ):
    xsl:value-of select="ddwrt:FormatDate(@ArticleStartDate, 2057, 1)"
  3. Save. Publish. Check results 😉

 

Tags:
Share this Story:
  • facebook
  • twitter
  • gplus