SharePoint - Conditional formatting with dates

Asked By Jorge Colon on 08-Feb-10 01:50 PM

I have a list where the date column changes color depending on how far away it is from the current date.  The code seems to work fine except when the specified date crosses into the following month.  For example, if today's date is within 7 days of Feb 28, 2010, the column changes to yellow. Lets say today's date is Feb 27, 2010.  This is within 7 days, the column changes to yellow.  However, if I change the column's date to Mar 1, 2010, it doesn't change to yellow, despite today being within 7 days of the column date.  Initially, I've tried this with 30 and 60 day conditions, but I've temporarily changed it to 3 and 7 day conditions for testing.  I had believe that the "number(translate(xxx))" function converts the date to a numeric value that increases by 1 everyday.  So I don't understand why this combination of conditions doesn't work beyond the current month.  Any thoughts on this topic?  Has anyone else run into a similar problem?

<xsl:attribute name="style">
  <xsl:if test="number(translate(substring-before(@Close_x0020_Out_x0020_Date,'T'),'-','')-7) &gt; number(translate(substring-before($Today,'T'),'-',''))">background-color: #008000; font-weight: bold;</xsl:if>
  <xsl:if test="number(translate(substring-before(@Close_x0020_Out_x0020_Date,'T'),'-','')-7) &lt;= number(translate(substring-before($Today,'T'),'-',''))" xmlns:ddwrt="">background-color: #FFFF00; font-weight: bold;</xsl:if>
  <xsl:if test="number(translate(substring-before(@Close_x0020_Out_x0020_Date,'T'),'-','')-3) &lt;= number(translate(substring-before($Today,'T'),'-',''))">background-color: #FFA521; font-weight: bold;</xsl:if>
  <xsl:if test="number(translate(substring-before(@Close_x0020_Out_x0020_Date,'T'),'-','')) &lt; number(translate(substring-before($Today,'T'),'-',''))">background-color: #FF0000; font-weight: bold;</xsl:if>

<xsl:value-of disable-output-escaping="no" select="ddwrt:FormatDate(string(@Close_x0020_Out_x0020_Date),number($Language),1)" />

Alon Havivi replied to Jorge Colon on 09-Feb-10 02:11 PM
It's look like there is comparison between the current date DAY and the selected date DAY... without considering the month or year values.