time values in if formulas excel 2007

D sweetman

New Member
Joined
Nov 1, 2015
Messages
11
Hi
See below a start and finish time of a shift. For John Doe I want the hours worked to read 24:00. See formulas used in the 2 hours worked for John and Peter.

StartFinishNameHours worked
14:00 Sleep over14:00John Doe00:00
16:00D/D21:00Peter Doe05:00

<tbody>
</tbody>


=IF(D3="";"";(IF((D3>B3);(D3-B3);(24-(B3-D3)))))


<tbody>
</tbody>
=IF(D4="";"";(IF((D4>B4);(D4-B4);(24-(B4-D4)))))

<tbody>
</tbody>

Thanks for any help
Regards
David
 
576 is a result of the formula (which is the wrong way round)

in 2007 Pizza > Excel Options > Advanced > Editing Options
 
Upvote 0

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
maybe replace
=IF(D4="";"";(IF((D4>B4);(D4-B4);(24-(B4-D4)))))
with
=ABS(D4-B4)
 
Upvote 0
See below a start and finish time of a shift. For John Doe I want the hours worked to read 24:00.
[....]
StartFinishNameHours worked
14:00 Sleep over14:00John Doe00:00

<tbody>
</tbody>
[....]
=IF(D3="";"";(IF((D3>B3);(D3-B3);(24-(B3-D3)))))

<tbody>
</tbody>

Change the formula to:

=IF(D3=""; ""; IF(D3 > B3; D3-B3; 1-(B3-D3)))

formatted as Custom [h]:mm.

Time is stored as a fraction of a day. So 1, not 24, represents 24 hours (one day).

PS: This is a good reason for using your formula instead of MOD(D3-B3,1), which is commonly suggested. Thanks for that.
 
Last edited:
Upvote 0
Thanks for your patience
I must be missing something.
I cant make the 576 show as 12:00 with my formula.
I'm guessing the problem is with my formula
This is my result at the moment with the formulas shown below
The times are in columns b and d
and the times are formatted as [H]:mm as advised

StartFinishNameHours worked
14:00Sleep over14:00John Doe576:00

<colgroup><col><col><col><col><col><col></colgroup><tbody>
</tbody>

16:00D/D21:00Peter Doe5:00

<tbody>
</tbody>

22:00D/D22:00Joe Doe576:00

<tbody>
</tbody>

=IF(D3="";"";(IF((D3>B3);(D3-B3);(24-(B3-D3)))))

<tbody>
</tbody>
This formula is giving 576 in the first line but I want it to show 24:00
=IF(D4="";"";(IF((D4>B4);(D4-B4);(24-(B4-D4)))))

<tbody>
</tbody>
This formula is giving the correct answer of 5:00
=IF(D5="";"";(IF((D5>B5);(D5-B5);(24-(B5-D5)))))

<tbody>
</tbody>


Thanks
 
Upvote 0
=IF(D3="";"";(IF((D3>B3);(D3-B3);(24-(B3-D3)))))

<tbody>
</tbody>
This formula is giving 576 in the first line but I want it to show 24:00
=IF(D4="";"";(IF((D4>B4);(D4-B4);(24-(B4-D4)))))

<tbody>
</tbody>
This formula is giving the correct answer of 5:00
=IF(D5="";"";(IF((D5>B5);(D5-B5);(24-(B5-D5)))))

<tbody>
</tbody>


Thanks
As Joeu2004 said 24 is 24 days (500 odd hours) change it to 1
 
Upvote 0
Hi again,
One last problem, I just noticed one person worked 24:30 see below but of course the hours worked comes up as 0:30.
I would like the formula to maybe know if the answer is less than 2 hours 24:00 should be added.
Or if cell c shows s/o which stands for sleep over and the hours are less than say 10 it will add 24:00 to the result.
I hope I'm explaining this right.

StartShiftFinishNameHours worked

<tbody>
</tbody>

14:00s/o14:30John Doe0:30

<tbody>
</tbody>

Regards
David
 
Upvote 0
you'll never have that problem if you ensure you have a start / finish date
 
Upvote 0

Forum statistics

Threads
1,215,471
Messages
6,124,998
Members
449,201
Latest member
Lunzwe73

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top