Hi,
Am Wed, 29 Jan 2014 12:30:00 -0800 (PST) schrieb
(e-mail address removed):
Claus, can you please explain the thinking behind the formula? Maybe to divide the formula in small pieces and explain?im asking because i would like to understand it and because i will need to do another formula for holidays with different shifts prices (7h-13h-22h) and i would like to try myself.
=IF(B2>A2
if you work without midnightrollover the end time is greater than the
start time and the first part of the formula is calculated
MIN(B2,TIME(22,,))
your dayshift goes up to 22:00. If you stop working before it calculates
the minimum of real end time and 22:00. If you stop working at 20:00
then 20:00 is the minimum. If you are working till 0:00 then 22:00 is
minimum.
MAX(A2,TIME(7,,)),0)
Your dayshift starts at 7:00. If you are starting later this calculates
the maximum of real start time and 7:00. If you are starting at 9:00
then 9:00 is maximum. If you are starting at 5:00 then 7:00 is maximum
MAX(MIN(B2,TIME(22,,))-MAX(A2,TIME(7,,)),0),MAX(TIME(22,,)-A2,0)
If you are working from 1:00 to 3:00 B2>A2 but if you calculate it with
the formula you get a negative time shown as #######
So the max(Formula,0) displays 0 cause 0 is greater than negative time
MAX(TIME(22,,)-A2,0)+MAX(B2-TIME(7,,),0))
With nightshift it is opposite to dayshift. You have to substract the
start time from 22:00 and 7:00 from end time.
Select a cell with the formula and start the formula editor and look how
it changes while calculating.
Regards
Claus B.