So I am attempting to format a date and time column via XSL and I am not having any luck. I have attempting using some of the suggested formats I have found online but nothing seems to work. I am using the ItemStyle.xsl ‘Default’ template to configure my Content Query Web Part. Below is the last formatting I have tried with the @PublishedDate field; highlighted in red. This is not working. Any Suggestions would be great.. Thanks in advance for the assist…
<xsl:stylesheet
version=”1.0″
exclude-result-prefixes=”x d xsl msxsl cmswrt”
xmlns:x=”http://www.w3.org/2001/XMLSchema”
xmlns:d=”http://schemas.microsoft.com/sharepoint/dsp”
xmlns:cmswrt=”http://schemas.microsoft.com/WebParts/v3/Publishing/runtime”
xmlns:xsl=”http://www.w3.org/1999/XSL/Transform” xmlns:msxsl=”urn:schemas-microsoft-com:xslt”>
<xsl:param name=”ItemsHaveStreams”>
<xsl:value-of select=”‘False'” />
</xsl:param>
<xsl:variable name=”OnClickTargetAttribute” select=”string(‘javascript:this.target="_blank"’)” />
<xsl:variable name=”ImageWidth” />
<xsl:variable name=”ImageHeight” />
<xsl:template name=”Default” match=”*” mode=”itemstyle”>
<xsl:variable name=”SafeLinkUrl”>
<xsl:call-template name=”OuterTemplate.GetSafeLink”>
<xsl:with-param name=”UrlColumnName” select=”‘LinkUrl'”/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name=”SafeImageUrl”>
<xsl:call-template name=”OuterTemplate.GetSafeStaticUrl”>
<xsl:with-param name=”UrlColumnName” select=”‘ImageUrl'”/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name=”DisplayTitle”>
<xsl:call-template name=”OuterTemplate.GetTitle”>
<xsl:with-param name=”Title” select=”@Title”/>
<xsl:with-param name=”UrlColumnName” select=”‘LinkUrl'”/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name=”cleanBody”>
<xsl:call-template name=”removeMarkup”>
<xsl:with-param name=”string” select=”@Body”/>
</xsl:call-template>
</xsl:variable>
<div class=”item”>
<xsl:if test=”string-length($SafeImageUrl) != 0″>
<div class=”image-area-left”>
<a href=”{$SafeLinkUrl}”>
<xsl:if test=”$ItemsHaveStreams = ‘True'”>
<xsl:attribute name=”onclick”>
<xsl:value-of select=”@OnClickForWebRendering”/>
</xsl:attribute>
</xsl:if>
<xsl:if test=”$ItemsHaveStreams != ‘True’ and @OpenInNewWindow = ‘True'”>
<xsl:attribute name=”onclick”>
<xsl:value-of disable-output-escaping=”yes” select=”$OnClickTargetAttribute”/>
</xsl:attribute>
</xsl:if>
<img style=”width:70px;height:50px” src=”{$SafeImageUrl}” title=”{@ImageUrlAltText}”>
<xsl:if test=”$ImageWidth != ””>
<xsl:attribute name=”width”>
<xsl:value-of select=”$ImageWidth” />
</xsl:attribute>
</xsl:if>
<xsl:if test=”$ImageHeight != ””>
<xsl:attribute name=”height”>
<xsl:value-of select=”$ImageHeight” />
</xsl:attribute>
</xsl:if>
</img>
</a>
</div>
</xsl:if>
<div class=”link-item”>
<xsl:call-template name=”OuterTemplate.CallPresenceStatusIconTemplate”/>
<a href=”{$SafeLinkUrl}” title=”{@LinkToolTip}”>
<xsl:if test=”$ItemsHaveStreams = ‘True'”>
<xsl:attribute name=”onclick”>
<xsl:value-of select=”@OnClickForWebRendering”/>
</xsl:attribute>
</xsl:if>
<xsl:if test=”$ItemsHaveStreams != ‘True’ and @OpenInNewWindow = ‘True'”>
<xsl:attribute name=”onclick”>
<xsl:value-of disable-output-escaping=”yes” select=”$OnClickTargetAttribute”/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select=”ddwrt:FormatDateTime(string(@PublishedDate), 1033, ‘dd-MMM-yyyy’)”/><br/>
<strong><xsl:value-of select=”$DisplayTitle”/></strong><br/>
Contributed by: <xsl:value-of select=”@Author” />
</a>
<div class=”description”>
<xsl:value-of select=”substring($cleanBody,1,175)” />…
</div>
</div>
</div>
</xsl:template>
Add this to the top of the XSL stylesheet section:
xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
I have tried the below to no avail. Any other suggestions? What am I missing here?
<xsl:value-of select=”ddwrt:FormatDateTime(@PublishedDate, 1033, 3)”/>
Â
Try this:
<xsl:value-of select=”ddwrt:FormatDate(@ArticleStartDate, 1033, 3)”/>