Home |
Search |
Today's Posts |
#5
![]() |
|||
|
|||
![]()
Discovered a bug.....
Try this: =IF(B1="","",IF(DAY(B1)=DAY(A1),MOD(B1,1)-MAX(MOD(A1,1),22/24),IF(MOD(A1,1)<MOD(B1,1),MIN(MIN(MOD(B1,1),6/24)-MOD(A1,1),6/24),IF(MOD(A1,1)<22/24,2/24+MIN(MOD(B1,1),6/24),1-MOD(A1,1)+MIN(MOD(B1,1),6/24))))*24) Biff "Biff" wrote in message ... Hi! Slightly shorter.... A1 = Date/Time in B1 = Date/Time out =IF(B1="","",IF(MOD(A1,1)<MOD(B1,1),MIN(MIN(MOD(B1 ,1),6/24)-MOD(A1,1),6/24),IF(MOD(A1,1)<22/24,2/24+MIN(MOD(B1,1),6/24),1-MOD(A1,1)+MIN(MOD(B1,1),6/24)))*24) Note: Discovered rounding discrepancies during testing but they do not effect the correctness of the results. For example: A1 = 8/7/2005 10:00 PM =MOD(A1,1) = 0.91666666666424100000 The time value: 10:00 PM is equivalent to 22/24 as used in the formula. However: 22/24 = 0.91666666666666700000 Biff "HappyTrucker" wrote in message ... OK, I think I've sorted it. Well it seems to work anyway. I don't know whether I stumped you all, or it just wasn't clear enough. Or maybe the problem wasn't interesting enough. Anyway, if anyone's interested, here's what I came up with eventually. And my God is it a loooong one: =IF(B15="","",IF(AND((B14<(LEFT(B14,5)+"22:00")),( B15<=(LEFT(B15,5)+"06:00"))),((B15-(LEFT(B14,5)+"22:00"))*24),IF(AND((B14=(LEFT(B14, 5)+"22:00")), (B15<=(LEFT(B15,5)+"06:00"))),(B15-B14)*24,IF(AND((B14(LEFT(B14,5)+"22:00")),(B15=( LEFT(B15,5)+"06:00"))),(((LEFT(B15,5)+"06:00")-B14)*24),8)))) ![]() -- HappyTrucker ------------------------------------------------------------------------ HappyTrucker's Profile: http://www.excelforum.com/member.php...o&userid=25997 View this thread: http://www.excelforum.com/showthread...hreadid=393601 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Adding hours and minutes | Excel Worksheet Functions | |||
creating a formula for a timecard obiding by CA OT laws | Excel Worksheet Functions | |||
Need a function that separates over-lapping work shift hours. | Excel Worksheet Functions | |||
calculate difference in time to hours | Excel Worksheet Functions | |||
need help w/formula for calculating overtime hours | Excel Worksheet Functions |