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

Ben picture Ben · Mar 10, 2011 · Viewed 10.9k times · Source

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.

Answer

Ben picture Ben · Mar 10, 2011

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'))