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

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
To further clarify:

if P27 = 3:00PM
and Q27 - 8:30PM

Answer should be 5.5. But it keeps coming up 5.
 
Upvote 0
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
275.5*3:00 PM8:30 PM

<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>
</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,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

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