Saturday, January 18, 2014

SharePoint 2013 CQWP ItemStyle.xsl - Match today's date

Following code demonstrate how we can match "Modified" date of an announcement and output if date is today rather than show date. 

List of LCID:
For list of LCID and Format also thanks goes to this blog:

<xsl:variable name="AnnModifiedDate" select="ddwrt:FormatDate(@Modified,3081,1)"/>
<xsl:variable name="TodayDate" select="ddwrt:FormatDate(ddwrt:Today(),3081,1)"/>
<span class="anndate">
    <xsl:when test="$AnnModifiedDate = $TodayDate">
      <xsl:value-of select="$AnnModifiedDate"/>

This code converts the Modified and Current date to Australian date format (d/m/yyyy) and does the match.
If matched outputs "Today" else the date.

No comments: