Bug With SharePoint 2010 XSLT DateFormat Function


The other day I found out that there is a problem/bug using the XSLT ddwrt:DateFormat function. The problem/bug occurs when the regional settings is not set to English (United States).

When a day has a value between 1 and 12, the ddwrt:DateFormat function will recognize this as the month. The month value will be used as the day.

So if the day value is less than 13, you get the following problem:

US Date Format ddwrt:DateFormatTime(date, 1043, ‘dd-MMMM-yyyy’)
8/6/2011 8-June-2011
2/3/2011 2-March-2011

When the day value is larger than 13, you get the correct formatting:

US Date Format ddwrt:DateFormatTime(date, 1043, ‘dd-MMMM-yyyy’)
8/19/2011 19-August-2011
2/28/2011 28-February-2011

I did not notice it in the beginning, because my settings are always set to English (United States) on my development server. When I implemented the XSLT stylesheet on a different environment, where the regional settings were set to Dutch (Belgium), some of dates were incorrectly formatted.

English (United States)

English (United States) Regional Setting

English date format converted to Dutch date format

Dutch (Belgium)

Dutch (Belgium) Regional Setting

Conversion problem with the Dutch date format


After some research and testing without result, I did some googling and found a post from someone who had the same problem. The blog post can be found here. In this blog post he included a custom XSL template to format the date.

I have created my own version of his XSL template to format the date in Dutch date format.

XSL Template

<xsl:template name="FormatDutchDate">
        <!– Template Parameters –>
        <xsl:param name="dateValue" />
        <xsl:param name="monthFormat" /> 
        <!– Split Date –>
        <xsl:variable name="day" select="substring-before($dateValue, ‘/’)" />
        <xsl:variable name="month" select="substring(substring-after($dateValue, ‘/’), 1, 2)" />
        <xsl:variable name="year" select="substring(substring-after(substring-after($dateValue, ‘/’), ‘/’), 1, 4)" />
        <!– Create US Date Format –>
        <xsl:variable name="USDate">
                <xsl:value-of select="$month" />/<xsl:value-of select="$day" />/<xsl:value-of select="$year" />
        <!– Month Notation –>
        <xsl:variable name="monthString">                                                
                        <xsl:when test="$monthFormat=’MM’">
                                <xsl:value-of select="$month" />
                        <xsl:when test="$monthFormat=’MMM’">
                                <xsl:value-of select="ddwrt:FormatDateTime($USDate, 1043, ‘MMM’)" />
                                <xsl:value-of select="ddwrt:FormatDateTime($USDate, 1043, ‘MMMM’)" />
        <!– Create Date –>
        <xsl:when test="string-length($day) = 1">0</xsl:when>
        <xsl:value-of select="$day" />-<xsl:value-of select="$monthString" />-<xsl:value-of select="$year" />

Call the XSL template

<xsl:call-template name="FormatDutchDate">
        <xsl:with-param name="dateValue" select="@Expires" />
        <xsl:with-param name="monthFormat">MMM</xsl:with-param>



XSLT Month Options

<xsl:with-param name="monthFormat">MM</xsl:with-param>

MM – Number notation

<xsl:with-param name="monthFormat">MMM</xsl:with-param>

MMM – Short Name Format

<xsl:with-param name="monthFormat">MMMM</xsl:with-param>


MMMM – Full Name Format