Problem : Find the Total Hours Completed between 5 pm –7am
Let’s say we have this Shift Time Data Row A1,B1,C1,D1
Shift in time 6:00AM 7:00AM 4:00PM
Row A2,B2,C2,D2
Shift out time 4:00PM 5:00PM 10:00PM
i need to calculate the total shift hours that fall between 5 pm to 7 am.
If the shift starts at 7 am and ends at 5 pm. The total hours clocked (between 5 pm and 7 am) will be 0
If the shift starts at 6 am and ends at 4 pm. The total hours clocked (between 5 pm and 7 am) will be 1
If the shift starts at 4 pm and ends at 10 pm. The total hours clocked (between 5 pm and 7 am) will be 5
See if this is what you want
=IF(AND(HOUR(B1)=6,HOUR(B2)=16),1,IF(AND(HOUR(B1)=7,HOUR(B2)=17),0,IF(AND(HOUR(B1)=16,HOUR(B2)=22),5,0)))
How about this:
=IF(B1>B2,MIN(24-HOUR(B1),7)+MIN(HOUR(B2),7),MAX(7-HOUR(B1),0)+MAX(HOUR(B2)-17,0))
Cheers,
Another try =IFERROR(INDEX({0,1,5},(MATCH(HOUR(B1),{7,6,16},0)+MATCH(HOUR(B2),{17,16,22},0))/2),0)
Cheers
Hi rathanak,
In addition to SunnyKow and ConnexionLosts's answers you can read up on time calculations
Phil
Thanks all it works fine
Cheers