+ Reply to Thread
Results 1 to 6 of 6

Calculating Hours Worked Past Midnight - Without no time entries equating to 24 hours.

  1. #1
    Registered User
    Join Date
    04-13-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    3

    Calculating Hours Worked Past Midnight - Without no time entries equating to 24 hours.

    Hi all,

    Thanks in advance on this, my first post so please bear with me!

    The point of this worksheet is equating additional hours worked and lieu time.

    I'm having an issue with working out what a formula should be for the following:-

    I have a worksheet with Date (A1) Time Started (B1) Time Finished (C1) Work Completed (D1) Hours Worked (E1) Holiday Used (F1)

    With the B1 & B2 formatted as h:mm AM/PM and D2 as Number to 2 Decimal places. The Work Completed column either has free text or "Holiday" or "Day Off" both of which have IF formulas on the phrase updating another table in sheet 2.

    Up to now I've been using =SUM(C1-B1)*24 in the Hours Worked column to work out the total amount of hours worked in a day however have just encountered the problem of working past midnight. As it returns a negative value instead of the total amount of hours.

    I've then managed to solve this using the following IF formula in Hours Worked column =IF(C1>B1,SUM(C1-B1)*24,((C1-B1)+1)*24)

    Again this works fine.

    The ACTUAL issue now is on Days Off - as no time is inputted into B1 or C1 - which with the above formula results in 24 Hours being recorded in Hours Worked... when it needs to obviously be zero (0).

    Can anyone think of a solution? In an ideal world i'd like to still be able to leave the time columns blank or have "Day Off" written into them which I'm hoping could then be incorporated into the IF formula above to equal a 0 in the Hours Worked (E1) column.

    Couple of JPG's now attached to help give a bit of context. (I know original columns are incorrect but it was just to try and keep it simple)

    Cheers!
    Attached Files Attached Files
    Last edited by mttomkins; 04-13-2017 at 10:28 AM.

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Calculating Hours Worked Past Midnight - Without no time entries equating to 24 hours.

    Attach a sample spreadsheet with expected results, not image files. Image files are impossible to edit and noone wants to retype the data for you.
    Remove any sensitive data, create a mockup example if necessary.
    Use the Go Advanced option at the bottom of the page then scroll down to Manage Attachments as the "paperclip" method does not work on this forum.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Calculating Hours Worked Past Midnight - Without no time entries equating to 24 hours.

    Hi, and welcome to the forum.

    It would have helped if you had uploaded the workbook rather than just a picture. Pictures are no use when we need to test solutions since none of us want to spend time creating a workbook you already have.

    However if I've understood the requirement the way to avoid negative time differences when times straddle midnight is to add 24 to the formula

    e.g
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    and to avoid cells with no times showing 24, wrap the formula in another if test. e.g.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    04-13-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    3

    Re: Calculating Hours Worked Past Midnight - Without no time entries equating to 24 hours.

    Thank you guys, apologies for attaching the image files rather than the doc. Have now updated.

    The row with formula mentioned above is in Week 9 and highlighted.

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Calculating Hours Worked Past Midnight - Without no time entries equating to 24 hours.

    Hi,

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    04-13-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    3

    Re: Calculating Hours Worked Past Midnight - Without no time entries equating to 24 hours.

    Richard I've just tried implementing those myself...

    The first one, solving the negative issue worked first time with the initial =SUM formula... meaning I didn't need the second part!

    Cant believe it was that simple I've spent all day trying to work that out for the Mrs!

    Thanks very much

+ 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. [SOLVED] Calculating hours worked even past midnight
    By tph1956 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 08-30-2013, 12:52 PM
  2. [SOLVED] Calculating hours worked beyond midnight
    By Boville in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-25-2012, 12:22 PM
  3. Replies: 0
    Last Post: 05-14-2012, 05:36 PM
  4. Using VB to address hours worked past midnight
    By ZooTV92 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-02-2012, 05:11 PM
  5. Calculating basic hours worked, between a time range and premium hours worked
    By RoyLittle0 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 01-07-2012, 06:59 AM
  6. Replies: 0
    Last Post: 01-05-2012, 06:23 AM
  7. Excel 2007 : Formula - hours worked past midnight
    By Belatrix101 in forum Excel General
    Replies: 10
    Last Post: 12-18-2009, 03:45 AM

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