感謝天道無常大您的詳細教導。
依您的範例,我已完成加班工時如下:如有疏漏,還煩請指正,謝謝!!
加班工時:C3為上班時間,D3為下班時間
方程式1 條件D3>C3
IF(D3>C3,xxx,0) 這個xxx要想辦法將三個條件(C3<900,D3>1700)放進去
IF(C3<900,方程式一,AAA)
IF(D3>1700,方程式二,0)
整合後方程式1:
IF(D3>C3,IF(C3<900,方程式一,IF(D3>1700,方程式二,0)),0)
方程式二: 條件D3>1700
IF(D3>1700,方程式二,0) 這個方程式二要想辦法將四個條件(AND(900<=C3,C3<1300),
AND(1300<=C3,C3<=1700),1700<C3, AND(900<=C3,C3<=1700))放進去
IF(AND(900<=C3,C3<1300),方程式三,AAA)
IF(AND(1300<=C3,C3<=1700),方程式四,BBB)
IF(1700<C3,方程式五,CCC)
IF(AND(900<=C3,C3<=1700),方程式六,0)
方程式三
=>IF(AND(D3>C3,D3>1700,900<=C3,C3<1300),((INT(D3/100)+MOD(D3,100)/60)-(INT(1700/100)+MOD(1700,100)/60)),0)
方程式四
=>IF(AND(D3>C3,D3>1700,1300<=C3,C3<=1700),((INT(D3/100)+MOD(D3,100)/60)-(INT(1700/100)+MOD(1700,100)/60)),0)
方程式五
=>IF(AND(D3>C3,D3>1700,1700<C3),((INT(D3/100)+MOD(D3,100)/60)-(INT(C3/100)+MOD(C3,100)/60)),0)
方程式六
=>IF(AND(D3>C3,D3>1700,900<=C3,C3<=1700),((INT(D3/100)+MOD(D3,100)/60)-(INT(1700/100)+MOD(1700,100)/60)),0)
整合後方程式二:
IF(AND(900<=C3,C3<1300),方程式三, IF(AND(1300<=C3,C3<=1700),方程式四,
IF(1700<C3,方程式五,IF(AND(900<=C3,C3<=1700),方程式六,0))))
帶入後方程式二:
IF(AND(900<=C3,C3<1300),((INT(D3/100)+MOD(D3,100)/60)-(INT(1700/100)+MOD(1700,100)/60)),IF(AND(1300<=C3,C3<=1700),((INT(D3/100)+MOD(D3,100)/60)-(INT(1700/100)+MOD(1700,100)/60)),IF(1700<C3,((INT(D3/100)+MOD(D3,100)/60)-(INT(C3/100)+MOD(C3,100)/60)),IF(AND(900<=C3,C3<=1700),((INT(D3/100)+MOD(D3,100)/60)-(INT(1700/100)+MOD(1700,100)/60)),0))))
方程式一: 條件C3<900
IF(C3<900,方程式一,0) 這個方程式一要想辦法將五個條件(D3<900,AND(900<=D3,D3<1300),AND(1300<=D3,D3<=1700),D3>1700,AND(900<=D3,D3<=1700))放進去
IF(D3<900,方程式七,AAA)
IF(AND(900<=D3,D3<1300),方程式八,BBB)
IF(AND(1300<=D3,D3<=1700),方程式九,CCC)
IF(D3>1700,方程式十,DDD)
IF(AND(900<=D3,D3<=1700),方程式十一,0)
方程式七
=>IF(AND(D3>C3,C3<900,D3<900),((INT(D3/100)+MOD(D3,100)/60)-(INT(C3/100)+MOD(C3,100)/60)),0)
方程式八
=>IF(AND(D3>C3,C3<900,900<=D3,D3<1300),((INT(900/100)+MOD(900,100)/60)-(INT(C3/100)+MOD(C3,100)/60)),0)
方程式九
=>IF(AND(D3>C3,C3<900,1300<=D3,D3<=1700),((INT(900/100)+MOD(900,100)/60)-(INT(C3/100)+MOD(C3,100)/60)),0)
方程式十
=>IF(AND(D3>C3,C3<900,D3>1700),((INT(900/100)+MOD(900,100)/60)-(INT(C3/100)+MOD(C3,100)/60))+((INT(D3/100)+MOD(D3,100)/60)-(INT(1700/100)+MOD(1700,100)/60)),0)
方程式十一
=>IF(AND(D3>C3,C3<900,900<=D3,D3<=1700),((INT(900/100)+MOD(900,100)/60)-(INT(C3/100)+MOD(C3,100)/60)),0)
整合後方程式一:
IF(D3<900,方程式七,IF(AND(900<=D3,D3<1300),方程式八,IF(AND(1300<=D3,D3<=1700),方程式九,IF(D3>1700,方程式十,IF(AND(900<=D3,D3<=1700),方程式十一,0)))))
帶入後方程式一:
IF(D3<900,((INT(D3/100)+MOD(D3,100)/60)-(INT(C3/100)+MOD(C3,100)/60)),IF(AND(900<=D3,D3<1300),((INT(900/100)+MOD(900,100)/60)-(INT(C3/100)+MOD(C3,100)/60)),IF(AND(1300<=D3,D3<=1700),((INT(900/100)+MOD(900,100)/60)-(INT(C3/100)+MOD(C3,100)/60)),IF(D3>1700,((INT(900/100)+MOD(900,100)/60)-(INT(C3/100)+MOD(C3,100)/60))+((INT(D3/100)+MOD(D3,100)/60)-(INT(1700/100)+MOD(1700,100)/60)),IF(AND(900<=D3,D3<=1700),((INT(900/100)+MOD(900,100)/60)-(INT(C3/100)+MOD(C3,100)/60)),0)))))
帶入後方程式1:(此即為加班工時完成版)
IF(D3>C3,IF(C3<900,IF(D3<900,((INT(D3/100)+MOD(D3,100)/60)-(INT(C3/100)+MOD(C3,100)/60)),IF(AND(900<=D3,D3<1300),((INT(900/100)+MOD(900,100)/60)-(INT(C3/100)+MOD(C3,100)/60)),IF(AND(1300<=D3,D3<=1700),((INT(900/100)+MOD(900,100)/60)-(INT(C3/100)+MOD(C3,100)/60)),IF(D3>1700,((INT(900/100)+MOD(900,100)/60)-(INT(C3/100)+MOD(C3,100)/60))+((INT(D3/100)+MOD(D3,100)/60)-(INT(1700/100)+MOD(1700,100)/60)),IF(AND(900<=D3,D3<=1700),((INT(900/100)+MOD(900,100)/60)-(INT(C3/100)+MOD(C3,100)/60)),0))))),IF(D3>1700,IF(AND(900<=C3,C3<1300),((INT(D3/100)+MOD(D3,100)/60)-(INT(1700/100)+MOD(1700,100)/60)),IF(AND(1300<=C3,C3<=1700),((INT(D3/100)+MOD(D3,100)/60)-(INT(1700/100)+MOD(1700,100)/60)),IF(1700<C3,((INT(D3/100)+MOD(D3,100)/60)-(INT(C3/100)+MOD(C3,100)/60)),IF(AND(900<=C3,C3<=1700),((INT(D3/100)+MOD(D3,100)/60)-(INT(1700/100)+MOD(1700,100)/60)),0)))),0)),0)