+ Reply to Thread
Results 1 to 11 of 11

Calculating times and hours

  1. #1
    Registered User
    Join Date
    09-27-2016
    Location
    Madison, Wisconsin
    MS-Off Ver
    2010
    Posts
    15

    Calculating times and hours

    I am trying to create a timecard that calculates hours and minutes based on actual times that I input into a cell.

    To break this down:

    Morning
    7:00am (A1) to 12:10pm (B1) [both formatted as h:mm AM/PM] so the total hours is =(B1-A1), or 5:10 (C1), formatted as [h]:mm;

    Afternoon
    12:50pm (D1) to 3:25pm (E1) (both formatted as h:mm AM/PM) so the total hours is =(E1-D1), or 2:35 (F1), formatted as [h]:mm;

    Now I want to add an overtime column (G1) that will subtract the [original hours] from the [original hours + the overtime hours], with the original MORNING hours always being 5:10 and the original AFTERNOON hours always being 2:35. So say I worked 2 hours of overtime in the afternoon, making cell (E1) 5:25 instead of 3:25. My total hours in (F1) would then be 4:35 instead of 2:35.

    In my OT cell (G1), I used this formula:

    =((C1)-"5:10")+((F1)-"2:35")

    Essentially, this is taking the total hours in the AM (5:10), subtracting 5:10 since that is the original hours, which equals 0, since no OT hours were worked in the AM. In the afternoon, this formula takes the total hours in the PM (4:35), and subtracts 2:35, since 2:35 is the original amount of hours, which should equal 2:00 hours.

    When I enter these figures into my spreadsheet, it will calculate the 2:00 hours, but if I try to drag and copy the formula, I get ####. It also won't add properly when I try to SUM all the OT cells.

    Does anyone have ANY idea how to make this work? It's literally driving me insane.
    Thanks!

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,808

    Re: Calculating times and hours

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Never use Merged Cells in Excel

  3. #3
    Registered User
    Join Date
    09-27-2016
    Location
    Madison, Wisconsin
    MS-Off Ver
    2010
    Posts
    15

    Re: Calculating times and hours

    I tried attaching, please let me know if it worked.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    29,968

    Re: Calculating times and hours

    Try

    In OT

    =ROUND((D5)-TIME(5,10,0)+(G5)-TIME(2,35,0),10)

  5. #5
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: Calculating times and hours

    Welcome to the forum.

    The #### is because Excel is finding a negative time (and it doesn't understand 'zero' time either, sometimes). If you change the 3:25 in F2 to 3:25:01, you'll get the answer you expect. However, if you change it to 3:24, you'll get the ##### error again, because the 'overtime' is negative.
    Try using this instead - it will put in 0 'manually' if the overtime calculates to less than or equal to 0:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    I haven't done much testing on this, so let me/us know if it doesn't work for some of your times.

    Edit: I combined your two times into one, but you could keep them separate:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by Aardigspook; 09-27-2016 at 03:40 PM. Reason: (1) Fix copy/paste error (2) add further comment
    Regards,
    Aardigspook

    I recently started a new job so am a bit busy and may not reply quickly. Sorry - it's not personal - I will reply eventually.
    If your problem is solved, please go to 'Thread Tools' above your first post and 'Mark this Thread as Solved'.
    If you use commas as your decimal separator (1,23 instead of 1.23) then please replace commas with semi-colons in your formulae.
    You don't need to give me rep if I helped, but a thank-you is nice.

  6. #6
    Registered User
    Join Date
    09-27-2016
    Location
    Madison, Wisconsin
    MS-Off Ver
    2010
    Posts
    15

    Re: Calculating times and hours

    THANK YOU! This does seem to work! The only thing now, I have one line with only morning hours and no afternoon hours. So it only goes:
    MORNING
    7:00 AM to 12:00 PM totaling 5:00 hours. When I copied the formula from above into all 5 OT cells for the week, I still got #### in this last row, I'm assuming because the time is different and we aren't adding any afternoon hours either. How do I modify that formula to make this last row work?

  7. #7
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: Calculating times and hours

    Which formula are you using - mine or John's?

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    29,968

    Re: Calculating times and hours

    Something like...

    =ROUND((D9)-TIME(5,0,0)+IF(G9>0,G9-TIME(2,35,0),0),10)

    You will get an error if you subtract 5:10.

    I find your OT calculation most confusing: most OT calculations are done based on a standard day of say 8 hours: hours in excess of this are OT.

  9. #9
    Registered User
    Join Date
    09-27-2016
    Location
    Madison, Wisconsin
    MS-Off Ver
    2010
    Posts
    15

    Re: Calculating times and hours

    Sorry--I didn't see your post before I responded. I have never used this site before so please bear with me!

    I used John's formula and it worked in all my rows (Monday thru Thursday), except Friday. Friday hours show 7:00 am to 12:00 pm with no afternoon hours, so I wasn't sure how to adjust his formula accordingly.

    @Aardigspook - I could not get your formula to work correctly.

  10. #10
    Registered User
    Join Date
    09-27-2016
    Location
    Madison, Wisconsin
    MS-Off Ver
    2010
    Posts
    15

    Re: Calculating times and hours

    For whatever reason, this isn't letting me respond to your individual messages.

    @JohnTopley - You are a lifesaver. That formula worked. THANK YOU. And I completely agree. We have a 36-hour work week here, so the numbers on this timecard are very confusing.

    Thank you both for your assistance!

  11. #11
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: Calculating times and hours

    You're welcome - glad we (John, at least) could be of help. Thanks for the feedback.
    If that's your problem solved, please mark the thread as solved so others know there's an answer here - see my sig for how.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. I need some help with calculating hours worked during various shift times
    By Minxy01 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-27-2015, 04:24 PM
  2. Scheduling, Calculating Hours Between Specific Times
    By bgregory12 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-03-2015, 01:01 AM
  3. calculating times greater then 24 hours
    By webstersemail in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-17-2014, 09:54 PM
  4. Calculating working hours between two dates/times!
    By JDGreen17 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-22-2013, 07:46 AM
  5. Calculating the hours between two specific times
    By izzyfuxx in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-05-2013, 09:38 AM
  6. Calculating (extracting) hours between two times
    By pointman787 in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 04-12-2012, 02:59 PM
  7. Calculating Hours between Dates and Times VBA
    By Crebsington in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-11-2012, 03:34 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1