nmgmarques
Board Regular
- Joined
- Mar 1, 2011
- Messages
- 133
- Office Version
- 365
- Platform
- Windows
Hi all. This question might get a bit lengthy so I'll jump right to it.
Company X builds cars. It does so between the hours of 8:15 and 17:05, from Monday to Friday. They have a 50 minute lunch break from 12:30 to 13:20. This gives us a total of 8 working hours per working day.
Under normal circumstances, they produce 8 cars per day, which gives us an average of 1 hour for each car.
For argument’s sake, lets say A1 to G1, contain the headers in this order, Cars, Start Date, Start Time, End Date, End Time, Total Time and Average. Let us also assume the following values for each cell from A2 to F2: 8, 24-Feb, 8:15, 24-Feb, 17:05, 8:00. G2 shall be automatically calculated and expressed as a number using the formula =(F2/A2)*24. In this example the value returned should be 1,00 or 1 (one) hour.
If I use the following expression in F2
=IF(AND(E2=B2;C2<0,5208333334);F2-C2-0,0347222222;0,3333333333*(E2-B2)+F2-C2)
Assuming the start and end dates are in fact the same, I get the correct result expressed in fractioned hours, as I change the times. To this point, there are no problems. My problems start if the end dates are different from the starting dates. This would imply the formula would first have to check if the days are similar or not, and then check if the start and end times occur before or after lunch breaks, in order to determine the number of hours worked and subtract the relevant number of lunch breaks in between the start and end times. This has proven to be beyond my reach. Hence my coming hear asking for help.
If at all possible, I would appreciate any info, or if you could at least point me in the right direction.
I thank you all in advance!
Company X builds cars. It does so between the hours of 8:15 and 17:05, from Monday to Friday. They have a 50 minute lunch break from 12:30 to 13:20. This gives us a total of 8 working hours per working day.
Under normal circumstances, they produce 8 cars per day, which gives us an average of 1 hour for each car.
For argument’s sake, lets say A1 to G1, contain the headers in this order, Cars, Start Date, Start Time, End Date, End Time, Total Time and Average. Let us also assume the following values for each cell from A2 to F2: 8, 24-Feb, 8:15, 24-Feb, 17:05, 8:00. G2 shall be automatically calculated and expressed as a number using the formula =(F2/A2)*24. In this example the value returned should be 1,00 or 1 (one) hour.
If I use the following expression in F2
=IF(AND(E2=B2;C2<0,5208333334);F2-C2-0,0347222222;0,3333333333*(E2-B2)+F2-C2)
Assuming the start and end dates are in fact the same, I get the correct result expressed in fractioned hours, as I change the times. To this point, there are no problems. My problems start if the end dates are different from the starting dates. This would imply the formula would first have to check if the days are similar or not, and then check if the start and end times occur before or after lunch breaks, in order to determine the number of hours worked and subtract the relevant number of lunch breaks in between the start and end times. This has proven to be beyond my reach. Hence my coming hear asking for help.
If at all possible, I would appreciate any info, or if you could at least point me in the right direction.
I thank you all in advance!