开发者

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

开发者 https://www.devze.com 2023-02-15 21:12 出处:网络
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

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 -开发者_StackOverflow社区

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.


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


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

精彩评论

暂无评论...
验证码 换一张
取 消