Calculating Hours with fractions for half hours

JAATL2014

New Member
Joined
Aug 6, 2014
Messages
3
I have a formula to calculate the number of hours between a start and end time....but cannot get a MROUND function to work, to give me a decimal of half hour.

P27 = Start time
Q27 = End Time

1) This formula gives me good answer if the times are full hours...but rounds down to the nearest whole number if not
=IF(ISBLANK(P27),"", IF(HOUR(Q27-P27)>0,HOUR(Q27-P27),24))

2) When I try to use MROUND with 1/48 to show half hours, it shows a bad formula. i.e.
=IF(ISBLANK(P27),"", IF(HOUR(Q27-P27)>0,MROUND(HOUR(Q27-P27),1/48),24))

(Note, the 24 is at the end of the formula to account for 24 hours (12a - 12a) periods.

Any help is appreciated
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Here is another way to write the fomula...

=IF(ISBLANK(P27),"",IF(Q27-P27>0,24*MROUND(Q27-P27,TIME(0,30,0))))

Note: You may have to manually set the cell format to "General" in order to see the floating point value.
 
Upvote 0
That did it, thank you


*NOPQ
*

<colgroup><col style="font-weight:bold; width:30px; "><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"></colgroup><tbody>
[TD="bgcolor: #cacaca, align: center"]27[/TD]
[TD="align: right"]5.5[/TD]

[TD="align: right"]3:00 PM[/TD]
[TD="align: right"]8:30 PM[/TD]

</tbody>

Spreadsheet Formulas
CellFormula
N27=IF(ISBLANK(P27),"", IF(Q27-P27>0,MROUND(Q27-P27,1/48)*24,24))

<tbody>
</tbody>

<tbody>
</tbody>



That did it, thank you.

Excel tables to the web >> Excel Jeanie HTML 4 [/QUOTE]
 
Upvote 0
You're welcome. Either formula should work for you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,238
Messages
6,170,939
Members
452,368
Latest member
jayp2104

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