I'm using SharePoint Foundation 2010 and we've added a blog as a subsite. I want to show a 'recent blog posts' webpart on the main site page, so decided to go down the route of an XML webpart using the rss feed from the blog.

This is working great, except the date format returned by the rss feed is like:

Wed, 02 May 2012 09:22:36 GMT

I just want it to be dd/MM/yyyy.

I tried referencing the ddwrt namespace in the header of the xsl file, but when I try to use:


to format the date, but I'm just getting 'Failed to apply XSLT to the content' whenever I do. works fine, and the ddrwrt reference I copied from an existing xsl file in SharePoint.

entire xsl (it's only short, don't worry!):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal" ddwrt:oob="true">
<xsl:output method="html" indent="no"/>
        <xsl:template match="/">
                <xsl:apply-templates select="rss/channel"/>
        <xsl:template match="rss/channel">
            <xsl:variable name="link" select="link"/>
            <xsl:variable name="description" select="description"/>
                    <xsl:apply-templates select="item"/>
        <xsl:template match="item">
            <xsl:variable name="item_link" select="link"/>
            <xsl:variable name="item_title" select="description"/>
            <xsl:variable name="item_author" select="author"/>
            <xsl:variable name="item_date" select="pubDate"/>
                <xsl:if test="position() &lt; 6">
                        <a href="{$item_link}" title="{$item_title}"><xsl:value-of select="title"/></a><br />
                        <span class="blog-date">
                            <xsl:value-of select="$item_date"/>
                        <span class="blog-author">
                            <xsl:value-of select="author"/>

If I change line 25 to:

<xsl:value-of select="$item_date" />

Then I get no errors, but the date is obviously in the full format.

This is day one of working with XSLT, so please be forgiving!

Also, I know that 1033,1 will not give the correct format, but I am just using it as a placeholder for now until I get the code working.

  • I managed to find a workaround for now. I used substring to pull the relevant sections of the formatted datetime string out to how I wanted them displayed. Hacky, but works for now. Got the idea from panvega.wordpress.com/2008/01/29/… May 2, 2012 at 14:11

3 Answers 3


Try this:

ddwrt:FormatDate(string($item_date) ,1038 ,1)

I am using this to format date to dd.mm.yyyy format.


Following should work

<xsl:value-of select="msxsl:format-date($item_date, 'dd/MM/yyyy')"/>
  • Interestingly, I don't get an error when I use that, but no result is returned at all... May 2, 2012 at 13:58

If you want it to be in "dd/MM/yyyy" format, you can use the FormatDateTime function like this:

ddwrt:FormatDateTime(@DueDate, 1033, 'dd/MM/yyyy') 
  • That still throws the error 'Failed to apply XSLT to the content.' May 2, 2012 at 13:59
  • Try this <xsl:value-of select= "ddwrt:FormatDate(string(@item_date), 1033, 1)"/> I am using this format and it is working for me
    – user8513
    May 24, 2012 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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