SharePoint Designer 2010 - Determine if today's date is within x days of a start date column using conditional formatting

10,951

Solution 1

The following worked for me:

number(ddwrt:FormatDateTime(ddwrt:FormatDate(string($thisNode/@StartDate),1033,1),1033,'yyyyMMdd')+3) <= number(ddwrt:FormatDateTime(ddwrt:FormatDate(string($Today),1033,1),1033,'yyyyMMdd'))

Solution 2

I don't know why, but this didn't work for me. The second FormatDateTime parameter - 'yyyyMMdd' - kept throwing an error.

This finally worked:

number(translate(substring-before(@StartDate,'T'),'-',''))+3 <= number(translate(substring-before($Today,'T'),'-',''))
Share:
10,951
Ben
Author by

Ben

Updated on June 28, 2022

Comments

  • Ben
    Ben almost 2 years

    I'm using SPD 2010 and Sharepoint Server 2010.

    Using conditional formatting I'm trying to format a list so that if today's date is greater than 3 days past the start date column a cell will turn red.

    Comparing two date columns directly (to see if today is after the start date) works well -

    ddwrt:DateTimeTick(ddwrt:GenDisplayName(string($thisNode/@StartDate))) < ddwrt:DateTimeTick(ddwrt:GenDisplayName(string($Today)))

    But if I add a number it will work in SPD design view, but not on the actual SharePoint site.

    ddwrt:DateTimeTick(ddwrt:GenDisplayName(string($thisNode/@StartDate))) + 3 < ddwrt:DateTimeTick(ddwrt:GenDisplayName(string($Today)))

    I tried converting 3 to ticks -> 8,640,000/day and using that value, but that didn't work either (and doesn't work in SPD design view).

    I can get the formatting to work if I create a column with a calculated date of "StartDate+3" and then compare that directly, however, it doesn't work if the column is not visible and I would rather not create additional columns.

    Any ideas?

    Thanks for you help.

  • adel
    adel almost 13 years
    You should tick to accept this answer to indicate the question is closed (useful to possible late answerers like myself). :)
  • Ben
    Ben almost 13 years
    Thanks Stuart, I was worried it was a StackOverflow faux pas to accept your own answer.
  • adel
    adel almost 13 years
    Thankfully not, but you don't get the +15 accepted answer bonus unfortunately.