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

只愿长相守 提交于 2019-12-10 22:58:56

问题


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.


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




回答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'),'-',''))


来源:https://stackoverflow.com/questions/5262878/sharepoint-designer-2010-determine-if-todays-date-is-within-x-days-of-a-start

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!