在sharepoint 2010计算列中计算开始时间和结束时间之间的天数时,如何排除周末(sat和sun)。
1.我有一个日历添加到sharepint 2010并且有两列作为开始时间和结束时间现在我的要求是计算星级时间和结束时间之间的天数,不包括周末(坐着和太阳)意味着它只会计算工作日。 试过这个
=IF(AND((WEEKDAY(EndDate,2))<(WEEKDAY(StartDate,2)),((WEEKDAY(StartDate,2))-(WEEKDAY(EndDate,2)))>1),(((DATEDIF(StartDate,EndDate,"D")+1))-(FLOOR((DATEDIF(StartDate,EndDate,"D")+1)/7,1)*2)-2),(((DATEDIF(StartDate,EndDate,"D")+1))-(FLOOR((DATEDIF(StartDate,EndDate,"D")+1)/7,1)*2)))
此外,
=(DATEDIF([StartDate],[EndDate],"d"))-INT(DATEDIF([StartDate],[EndDate],"d")/7)*2-IF((WEEKDAY([EndDate])-WEEKDAY([StartDate]))>0,2,0)+1
但没有得到正确的输出。
由于
答案 0 :(得分:2)
=IF(AND((WEEKDAY(EndDate,2))<(WEEKDAY(StartDate,2)),((WEEKDAY(StartDate,2))-(WEEKDAY(EndDate,2)))>1),(((DATEDIF(StartDate,EndDate,"D")+1))-(FLOOR((DATEDIF(StartDate,EndDate,"D")+1)/7,1)*2)-2),(((DATEDIF(StartDate,EndDate,"D")+1))-(FLOOR((DATEDIF(StartDate,EndDate,"D")+1)/7,1)*2)))
这应该可以解决问题:)
答案 1 :(得分:1)
不知道为什么,但我以-1结束,即:
=IF(AND((WEEKDAY(EndDate,2))<(WEEKDAY(StartDate,2)),((WEEKDAY(StartDate,2))-(WEEKDAY(EndDate,2)))>1),(((DATEDIF(StartDate,EndDate,"D")+1))-(FLOOR((DATEDIF(StartDate,EndDate,"D")+1)/7,1)*2)-2),(((DATEDIF(StartDate,EndDate,"D")+1))-(FLOOR((DATEDIF(StartDate,EndDate,"D")+1)/7,1)*2)))-1
用这种方式对我有用。
答案 2 :(得分:0)
尝试以下公式:
=DATEDIF([Start Date],[End Date],"D")-IF(WEEKDAY([End Date])=7,FLOOR((DATEDIF([Start Date],[End Date],"D")+WEEKDAY([Start Date]))/7,1)*2,FLOOR((DATEDIF([Start Date],[End Date],"D")+WEEKDAY([Start Date]))/7,1)*2+1)+IF(WEEKDAY([Start Date])=7,2,1)
答案 3 :(得分:0)
这对我来说效果最好。
ROUNDUP(([End Time]-[Start Time]),0)-IF(WEEKDAY([End Time])=7,FLOOR((DATEDIF([Start Time],[End Time],"D")+WEEKDAY([Start Time]))/7,1)*2,FLOOR((DATEDIF([Start Time],[End Time],"D")+WEEKDAY([Start Time]))/7,1)*2+1)+IF(WEEKDAY([Start Time])=7,2,1)
答案 4 :(得分:0)
计算sp中的网络天数的公式经过测试并工作:
=(DATEDIF([Start Date],[End Date],"D"))-INT(DATEDIF([Start Date],[End Date],"D")/7)*2-
IF(WEEKDAY([End Date])<WEEKDAY([Start Date]),2,
IF(OR(WEEKDAY([End Date])=7,WEEKDAY([Start Date])=1),1,0))+1