Question : Comparing two Time Values in Excel

I have a timesheet which correctly calculates hours worked (with data in the format 23:50:00 etc), even when a shift starts on one day and ends on the next. However, not all of the hours worked attract the same pay rate. Therefore, I need a formula / formulae, which:
1) Compares shift start times to a target time of 19:59:59, so all shifts starting at or after 20:00:00 are flagged up.  
2) Compares shift end times to determine those shifts that have ended at or before 6am.
3) For shifts which meet at least one of the 2 conditions above, calculates whether at least 50% of the hours worked, fall within the time range 20:00:00 to 06:00:00. (N.B. note that this time interval will always be spanning two different days).  

Answers avoiding VBA solutions if possible, would be particulalry appreciated.

Answer : Comparing two Time Values in Excel

Sorry I had an extra AND in that formula that should be there, this is the correct version

=IF(COUNT(A2,B2)=2,AND(OR(A2*24>=20,B2*24<=6),MEDIAN(1-A2,0,"4:00")+MEDIAN(B2,0,"6:00")>=MOD(B2-A2,1)/2),"")

should cope with any shift

regards, barry

Random Solutions  
 
programming4us programming4us