Bug With SharePoint 2010 XSLT DateFormat Function
This post is over a year old, some of this information may be out of date.
Yesterday I found out that there is a problem/bug using the XSLT ddwrt
function. The problem/bug occurs when the regional settings is not set to English (United States).When a day got the value between 1 and 12, the ddwrt
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 |
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/19/2011 | 19-August-2011 |
2/30/2011 | 30-February-2011 |
English (United States)


Dutch (Belgium)


Solution
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" /> </xsl:variable>
<!-- Month Notation --> <xsl:variable name="monthString"> <xsl:choose> <xsl:when test="$monthFormat='MM'"> <xsl:value-of select="$month" /> </xsl:when> <xsl:when test="$monthFormat='MMM'"> <xsl:value-of select="ddwrt:FormatDateTime($USDate, 1043, 'MMM')" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="ddwrt:FormatDateTime($USDate, 1043, 'MMMM')" /> </xsl:otherwise> </xsl:choose> </xsl:variable>
<!-- Create Date --> <xsl:choose> <xsl:when test="string-length($day) = 1">0</xsl:when> </xsl:choose> <xsl:value-of select="$day" />-<xsl:value-of select="$monthString" />-<xsl:value-of select="$year" /></xsl:template>
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></xsl:call-template>
Result

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

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

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

Related articles
How to Display the Site Title and Site URL in Search Results
Use Fiddler In Combination With SharePoint Designer to Retrieve Data Source Information
Data View Web Part: Create a Google Chart With XSLT
Report issues or make changes on GitHub
Found a typo or issue in this article? Visit the GitHub repository to make changes or submit a bug report.
Comments
Let's build together
Manage content in VS Code
Present from VS Code