Simple hour vs day formula

sassriverrat

Well-known Member
Joined
Oct 4, 2018
Messages
655
Good Evening,

I have a formula here that calculates the time difference from one date to another. It should spit this back in whole hours and it does. However, if I go over 23 hours (i.e. noon to noon), it goes back to zero because I think it's taking out a day. I need it to be able to hit 24+ hours. How might I fix this?

Note:
D4 is a time (both the active and the previous sheet)
F4 is a date (both the active and the previous sheet)

Code:
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
have you formatted as time [h]:mm and NOT h:mm
 
Upvote 0
Hello,

You can use formula :

=Mode(b2-a2,1)

HTH
 
Upvote 0
@James006

So I threw this together and it equals 1 if the period is 24hrs (1200 to 1200) but as soon as it should be 25hrs (1200-1300 the next day), it kicks out. Basically, I need this thing to give me an hour count between two dates/times.

Rich (BB code):
=mode((HOUR(ABS((($D$4+$F$4)-((PrevSheet($D$4)+PrevSheet($F$4)))))),1)
 
Upvote 0
Hmmmm.... @steve the fish

makes perfect sense to me. I wonder why I would have had "Hour" in the front of that....I'm sure I had a reason but I can't think of it.
the adjacent cell has minutes in it so I basically have the same formula but with "minute(abs etc etc)" and it works.
 
Upvote 0
You will have the same trouble with minutes if you want them to go over 60.
 
Upvote 0
No no minutes are only supposed to go up to 59
and then pop up the hour and reset the minutes to 00 and never hit 60
 
Upvote 0
unless you format as TIME with square brackets around the hour you will not see greater than 23
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,160
Members
453,021
Latest member
Justyna P

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