在excel中计算6次之间的小时数

时间:2018-08-22 12:17:56

标签: excel-formula

在hh:mm,B:C,D:E和F:G中有3次输入和输出。 Image H23 =MOD(C23-B23,1)*24+MOD(E23-D23,1)*24+MOD(G23-F23,1)*24中的公式 I23 =MOD(D23-C23,1)*C23+MOD(F23-E23,1)*24

中的公式

问题是,如果我将时间保持为零,而没有输入或输出任何数据,则结果不确定。

2 个答案:

答案 0 :(得分:0)

Your formula was more or less ok, it just didn't include condition to ignore the incomplete information. The condition is simple, it makes part of the formula work only in case that both In and Out informations are filled. Here's my formula for Prod Hrs:

=IF(AND(NOT(ISBLANK(C2)),NOT(ISBLANK(B2))),(C2-B2)*24,0)+IF(AND(NOT(ISBLANK(E2)),NOT(ISBLANK(D2))),(E2-D2)*24,0)+IF(AND(NOT(ISBLANK(G2)),NOT(ISBLANK(F2))),(G2-F2)*24,0) 

And here's one for non-Prod Hrs:

=IF(AND(NOT(ISBLANK(D2)),NOT(ISBLANK(C2))),(D2-C2)*24,0)+IF(AND(NOT(ISBLANK(F2)),NOT(ISBLANK(E2))),(F2-E2)*24,0)

答案 1 :(得分:0)

这有效! =MAX(0,IF(AND(NOT(ISBLANK(D24)),NOT(ISBLANK(C24))),(D24-C24)*24,0)+IF(AND(NOT(ISBLANK(F24)),NOT(ISBLANK(E24))),(F24-E24)*24,0)-1)