Date format is not correct in the DataFormWebPart SharePoint 2010

Ok there is some problem when formatting date’s which is different than US format when using XsltListViewWebPart has defined by Microsoft. This happens because the ddwrt:FormatDate function expects the data format to be in UTC and the XSLTListViewWebPart returns the date preformatted to the Web Locale or Locale Date/Time .

To fixing this issue Microsoft has released a new feature ,A new Property, EnableOriginalValue, has been added to the XlstListViewWebPart that unblocks this scenario by February CU 2012.

You can check fallowing article for more information:

For DataFormWebPart;the option is to use the DataFormWebPart with the following property set to false on the <SPDataSource> tag: UseServerDataFormat.
Make UseServerDataFormat property set to false the DataFormWebPart will receive the Date/Time in UTC format and then the ddwrt:FormatDate function will work accurately.

Or you can use power of xslt to format date as you wish:
Fallowing example will help you to how to do it.

Add fallowing codes in DataFormWebPart for suitable place for xsl:template

<xsl:template name=”FormatCorrectDate”>
<xsl:param name=”dateValue” />
<xsl:param name=”monthFormat” />

<!– Sperater is important here it should be “.” or “/” according your current language settings –>
<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=’M1′”>
<xsl:value-of select=”$month” />

<xsl:when test=”$monthFormat=’M2′”>
<xsl:value-of select=”ddwrt:FormatDateTime(string($USDate), 1055, ‘MMM’)” />
<xsl:value-of select=”ddwrt:FormatDateTime(string($USDate), 1055, ‘MMMM’)” />


<!– Create Date –>
test=”string-length($day) = 1″>0</xsl:when>

<xsl:value-of select=”$day” />-<xsl:value-of select=”$monthString” />-<xsl:value-of select=”$year” />

Call formatting template where you can needed in code :

<xsl:call-template name=”FormatCorrectDate”>
<xsl:with-param name=”dateValue” select=”string(@Created)” />
<xsl:with-param name=”monthFormat”>M2</xsl:with-param>



Getting error of “Unable to display this Web Part” on WSS2.0/SPS2003 after installing MS11-074

September Security Bulletin (MS11-04) is affecting WSS 2.0/SPS2003 ,  After installing security update MS11-074 for Windows SharePoint Services 2.0 / SharePoint Portal Server 2003 (KB 2494007), we are faced with problems with some DataViewWebPart s.
The error message is :
Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Windows SharePoint Services-compatible HTML editor such as FrontPage. If the problem persists, contact your Web server administrator.”

the problem is cause by The Security Update breaks some XSLT ddwrt functions in the Data View Web Part, for example, ddwrt:FormatDate(string szDate, long lcid, long formatFlag) and ddwrt:FilterLink().

For resolving this issue you ;

1) Upgrade to Windows SharePoint Services 3.0 or Office SharePoint Server 2007.
2. Evaluate how widely the Data View Web Part is used and apply the following workaround if there are very few pages affected:
Remove broken ddwrt functions in the Extensible Stylesheet Language Transformation (XSLT) code of the Data View Web Part.
Here is an example when the broken ddwrt function is
ddwrt:FormatDate(string szDate, long lcid, long formatFlag):

Replace code “ddwrt:FormatDate(string(@someDateField), 1033, 5)” with “@someDateField”. By applying this work around, the Data View will render in browser, however, the formatting of the Date field will be changed as following:

Before the security update, the date is in this format: 9/27/2011 6:21 PM
After above work around, the date is in this format: 2011-09-27T18:21:03

Another example, ddwrt:FilterLink(), this function returns an empty string. Just remove the function, the Data View should render the same way as before.

The above concept can be applied to other ddwrt functions with caution. There are possibilities that removing ddwrt functions will impair the function of XSLT so that the data displayed in Data View is not in the desired format. In those situations, please consider option 1 or 3.

3. Rollback the WSS 2.0/SPS 2003 farm to a state prior to installing the above Security Update. A backup of the farm/content databases before the security update is required for this to be successful.