若是不考慮調休:變量
=NETWORKDAYS(C2,D2,holidays)工作
若是考慮到調休:日期
維護一個表, 包括節假日和週末 (只含放假的日期, 不含調成上班的)
=NETWORKDAYS.INTL(D2,C2,"0000000",Holiday!A:A)-1
這個公式, "0000000" 7個0表示一週都是工做日, 維護的holiday來判斷放假的日期,"D2"是週末的不用在最後-1 (能夠IF(weekday())判斷下就好了)tar
若是再把最終結果是0或者-1的狀況考慮進來:
=IF(IF(OR(WEEKDAY(D2)=7,WEEKDAY(D2)=1),NETWORKDAYS(D2,E2,holidayIT),NETWORKDAYS(D2,E2,holidayIT)-1)<=0,1,IF(OR(WEEKDAY(D2)=7,WEEKDAY(D2)=1),NETWORKDAYS(D2,E2,holidayIT),NETWORKDAYS(D2,E2,holidayIT)-1))
看起來很長,提取出變量來看就簡單了
var IsStartDayWeekend = OR(WEEKDAY(D2)=7,WEEKDAY(D2)=1)
var businessDays = NETWORKDAYS(D2,E2,holidayIT)
var businessDaysNoWeekend = IF(IsStartDayWeekend,businessDays,businessDays-1)
這三個變量提取出來,表達式就剩下這點了 =IF(businessDaysNoWeekend<=0,1,businessDaysNoWeekend)