SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm editing the itemstyle.xsl to produce my own styling for a Content Query Web Part (CQWP) as follows: (NB - 2 laternative lines of code are shown as (A) and (B)

<xsl:template name="MyNewStyle" match="Row[@Style='MyNewStyle']" mode="itemstyle">
<div class="SipAddress">
  <xsl:value-of select="@SipAddress" />
<div class="LinkToolTip">
  <xsl:value-of select="@LinkToolTip" />
<div class="OpenInNewWindow">
  <xsl:value-of select="@OpenInNewWindow" />
<div class="OnClickForWebRendering">
  <xsl:value-of select="@OnClickForWebRendering" />
   <table width="100%" >
      <td width="45%" ><xsl:value-of select="@Title" /></td>
       <td width="33%"><xsl:value-of select="@Location" /></td>
       (A) <td width="32%"><xsl:value-of select="@EventDate"/></td>
       (B) <td width="32%"><xsl:value-of select="msxsl:format-date(@EventDate, 'dd/mm/yyyy h:mm')"/></td>


Using line (A) works in that all the data is all pulled through (I have also edited the CommonViewField in the webpart)

However the date appears in this format: 2011-04-21 10:00:00

So after a bit of googling I came across this: and replaced (A) with (B)

The date field disappeared... (sigh)

What do I need to do to make the date appear in the correct format?

share|improve this question
up vote 4 down vote accepted

After looking for ages for the answer to this I stumbled on it minutes after posting this question...

Anyway, the answer is here:


  1. Reference the ddwrt namespace at the top of the itemstyle.xls xmlns:ddwrt=""

  2. Now you can use the FormatDate function anywhere you like:

    <xsl:template name="Default" match="*" mode="itemstyle">
    <xsl:value-of select="ddwrt:FormatDate(@ArticleStartDate, 2057, 3)"/>

share|improve this answer
Nice tip! Sometimes just writing out the problem is the way to a solution. – Marc D Anderson Mar 30 '11 at 15:20
Great Post! But Im having hard time implementing on my portal using XsltListViewWebPart <xsl:apply-templates select="." mode="PrintFieldWithECB"> <xsl:with-param name="thisNode" select="$thisNode"/> </xsl:apply-templates> where $thisNode = Responded_x0020_On DateTime Type I tried doing the 2 sample but none of them seems to work. <xsl:value-of select="ddwrt:FormatDate(string(@Responded_x0020_On , 2057, 3)" /> <xsl:value-of select="ddwrt:FormatDate(@Responded_x0020_On , 2057, 3)"/> Any idea? Thanks. – R2C3 Apr 26 '12 at 11:37

I found this as the easiest way to limit the date field.

 < xsl:variable name="cDate" select="@cDate"></xsl:variable>

 < xsl:value-of disable-output-escaping="yes" select="substring-before($cDate,' ')"></xsl:value-of>
share|improve this answer
Anonymous user notes that it works if you only want to display date and not the time. – SPDoctor May 9 '13 at 21:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.