Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

how to calculate time difference in excel working hours only

How can I calculate hours worked on a project using specific working hours that aren't the same each day?

So Monday - Friday I work 7 am-7 pm, Saturday 9 am -1 pm and I take Sunday off (lucky me). If i start a project on the 1st March 10 am and finish on the 5th March at 9 am how can I calculate an answer of 27 hours ??

I have two cells date/time start and date/time finish. I have multiple rows to do this to and several time points but this essentially will work the same.

I hope makes sense.

Edit - Solutions tried and opposing results enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You will need a helper column with this formula:

=24*(SUMPRODUCT((TEXT(ROW(INDEX(AAA:AAA,$F$1):INDEX(AAA:AAA,$F$2)),"dddd")=A1)*(C1-B1))-IF(TEXT($F$1,"dddd")=A1,MOD($F$1,1)-B1,0)-IF(TEXT($F$2,"dddd")=A1,C1-MOD($F$2,1),0))

Then sum that column.

enter image description here


Here it is in one formula using NETWORKDAYS.INTL

=IF(DATEDIF(F1,F2,"d")>1,NETWORKDAYS.INTL(F1+1,F2-1,"0000011")*12+NETWORKDAYS.INTL(F1+1,F2-1,"1111101")*4,0)+IF(DATEDIF(F1,F2,"d")>0,(MOD(F2,1)-IF(WEEKDAY(F2,2)<6,TIME(7,0,0),TIME(9,0,0)))*24+(IF(WEEKDAY(F1,2)<6,TIME(19,0,0),TIME(13,0,0))-MOD(F1,1))*24,(F2-F1)*24)

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...