Excel/Calculating times

Advertisement


Question
QUESTION: Hi Tom

I need a spreadsheet that will calculate hours worked from start and finish times, eg I would like to enter a start time of 8am, finish time 4.30pm with 30 mins for lunch and arrive at a total hours worked of 8 hours worked.  I have tried to format the cells as time, but it isnt working.  Do you know a good way to do this?

ANSWER:
a1:  8:00 AM
B1:  4:30 PM
C1:  =B1-A1-time(0,30,0)

custom format C1 as hh:mm  or h:mm

and it will display 8:00
if you don't want to show minutes then custom number format a h

if you actually want the number 8 stored in the cell then format it as general and change the formula to

=(B1-A1-time(0,30,0))*24


time is stored as the fraction of a day.  If you wanted to enter 8 AM as the way it was stored you would put in
.333333333333333
for noon
.5

if you then format those cells at Time, they will appear as 8:00 or 8:00 AM depending on how you format it.  (or for noon)

and so forth.

to convert .333333333333333 to be 8 hours, multiply it by 24

=.333333333333333 * 24 = 8

--
Regards,
Tom Ogilvy





---------- FOLLOW-UP ----------

QUESTION: The first option is working fine, thanks very much.  I now need to sum the hours worked each day, but I am getting a strange result.  4 days at 8 hours should sum to 32hours, but I am getting 8 hours?  Can you help me with this?  I have formatted the total cell the same as the others, ie H:MM.

Thanks

Gail

Answer
Gail,

format the total cell as [h]:mm

Time is really stored as a date - so it is Date/Time

the number stored is the number of days from a base date  (Midnight of Dec 31, 1899; i.e. beginning of 1900.   So 2 January 1900 as noon would be   1.5:  1 and 1/2 day.

when you add up your times and they result in a number larger than 24, excel sees that as 8 AM on 2 January.  So it only shows the 8 hours.   when you enclose the h in brackets, it tells excel to show total hours and not treat the value as a data and time, but only as a time.

--
Regards,
Tom Ogilvy

About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

All Answers


Answers by Expert:


Ask Experts

Volunteer


Tom Ogilvy

Expertise

Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]

Experience

Extensive experience.

Education/Credentials
Master of Science (MS) degree Operations Research (ORSA)

Awards and Honors
Microsoft MVP in Excel.

©2016 About.com. All rights reserved.