Converting Time to Hours & Minutes

P

pugsly8422

I have time sheets that people fill out and and calculate by hand. I would
like to insert a formula that will calculate the hours and minutes worked.
An example would be:

Time In Time Out Time In Time Out # Hours
8am 11am 12pm 5:30pm 8.5


It would be even better if I could get "8 Hours and 30 Minutes" instead of
just "8.5." I'm thinking the only way to do this would be to use army time
because the am or pm will just get in the way of the calculation, but if it
is possible to leave that would be great as well.

Thanks in advance for any assistance! Let me know if there is any
additional information needed.
 
J

Jon Peltier

Format the inputs as times (this is as simple as entering a number, a space,
and am or pm), then use a little math. This formula calculates the elapsed
time:

=B3-A3+D3-C3

assuming the entered values are in A3 to D3. E3 will also have a format of
0:00 AM/PM. Select the cell, go to Format menu > Cells, and on the number
tab, choose a time format without am/pm.

- Jon
 
P

pugsly8422

Thanks a lot for your help. The only place I am still getting an error is
when the time goes from PM to AM. Here is what I input:


6:47 PM 11:08 PM 11:55 PM 4:38 AM #NUM!

I'm assuming I am getting the error because it is subtracting the AM from
the PM at the end. Is there any way to avoid this?

Thanks again for your assistance.
 
J

Jon Peltier

You either have to assume that the PM is from the day before and use

=B3-A3+D3+if(C3>D3,1,0)-C3

or enter the date and time in the four cells, but only display the time. The
second approach is more robust.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______
 
D

David Biddulph

Try =MOD(B3-A3+D3-C3,1)
though I'm surprised that you're getting a #NUM! from =B3-A3+D3-C3, as it
normally shows a ####### if you get a negative time.
 
P

pugsly8422

Both of the formulas worked. Thanks again for the help from both of you, it
is greatly apprecaited!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top