+ Reply to Thread
Results 1 to 9 of 9

Calculating time differences in 24 hour time when going past midnight

  1. #1
    Registered User
    Join Date
    05-24-2013
    Location
    Liverpool, England
    MS-Off Ver
    Excel 2007
    Posts
    9

    Calculating time differences in 24 hour time when going past midnight

    Hi

    I have a sheet detailing employee shift times. This contains their start and end time. Employees receive a standard pay during the hours of 6am until midnight and then receive a bonus pay for hours worked between midnight and 6am.

    I need separate formulas to work out how many standard hours were worked during a shift and how many bonus hours were worked during a shift

    So in the example shown, the number of standard hours in cell C2 would be 5 (22:00 - 00:00 & 6:00 - 9:00) and the number of bonus hours in cell D2 would be 6 (00:00 - 6:00).

    I have a formula for Standard hours when a shift is competed on a single day i.e. 6:00 - 14:00 but not for when a shift goes past midnight.

    Explanations of any formulas would be greatly appreciated.

    Thank you
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Calculating time differences in 24 hour time when going past midnight

    Formula for C2 then fill down

    =IF(B2<A2,1-A2,IF(A2>=0.25,B2-A2,B2-0.25))*24

    Formula for D2 then fill down

    =IF(A2<0.25,0.25-A2,IF(B2<A2,IF(B2>=0.25,0.25,B2),0))*24
    Last edited by mehmetcik; 03-28-2018 at 04:26 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Calculating time differences in 24 hour time when going past midnight

    Standard Hours: C2 =IF(AND(A2>0.25,A2<=1),1-A2,0)+IF(AND(B2>=0,B2<=0.25),0,B2-0.25)
    Bonus Hours: D2 =IF(B2>0.25,0.25,B2)

    and of course, the time format e.g. [h]:mm
    Last edited by mjr veverka; 03-28-2018 at 05:17 PM.

  4. #4
    Registered User
    Join Date
    05-24-2013
    Location
    Liverpool, England
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Calculating time differences in 24 hour time when going past midnight

    Thank you for the replies

    First to Mehmetcik, the formula for the bonus hours seems to work fine but the one for the standard hours doesn't seem to work for the shifts that go past midnight.
    It returns a result of 2 for the first shift in my example sheet when the answer should be 5.

    Secondly to Porucha Vevrku, Your formula seems to work for the first two shifts for the standard hours but then returns a result of 26 for the last one on my sheet. Not sure how that has happened.
    Also for the bonus hours it returns a result of 6:00 for each of them when it should be 6,3 and then 0.
    I also don’t want the result to be in hours and minutes but hours only. So instead of a shift being 4h:30m it would just be 4.5 hours.

    Thank you again for your quick replies. If you know how these could be amended to get the correct results I would appreciate it very much.
    I feel they are both very close to what I am asking for and I have included the sheet with your formulas so you can see what results I got, with Mehmetcik on top and Porucha Vevrku underneath.
    Attached Images Attached Images
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Calculating time differences in 24 hour time when going past midnight

    Quote Originally Posted by Thug View Post
    Calculating time differences in 24 hour time when going past midnight
    Quote Originally Posted by Thug View Post
    ...standard ... during the hours of 6am until midnight and then ... a bonus ... for hours worked between midnight and 6am.

    ... in the example ... the number of standard hours in cell C2 would be 5 (22:00 - 00:00 & 6:00 - 9:00) and the number of bonus hours in cell D2 would be 6 (00:00 - 6:00).
    1. Start time = 3.00 => End time = 10.30
    Where is "midnight" here ?
    Are you suggesting that someone works 31.5 hours continuously ?
    E.g. from 03/27/2018, 03:00 => to 03/28/2018, 10:30

    2. Start time = 10.00 => End time = 18.00
    If it happens within one work day, then where is "midnight" here ?
    E.g. from 03/27/2018, 10:00 => to 03/27/2018, 18:00,
    or maybe it is
    from 03/27/2018, 10:00 => to 03/28/2018, 18:00 => 32 hours of continuous work ?

    Specify your criteria more precisely.

  6. #6
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Calculating time differences in 24 hour time when going past midnight

    Assuming shift hours is not exceed 24 hours
    Try in C2:
    Please Login or Register  to view this content.
    D2:
    Please Login or Register  to view this content.
    Quang PT

  7. #7
    Registered User
    Join Date
    05-24-2013
    Location
    Liverpool, England
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Calculating time differences in 24 hour time when going past midnight

    I just thought I'd add some that didn't go past midnight to test the formula for all types of shifts i.e one that started in the middle of the bonus hours zone and a normal day shift only including standard hours.

    My fault for not explaining that. Sorry.

  8. #8
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Calculating time differences in 24 hour time when going past midnight

    You can also set it up by ranges using "IF" and "AND", "a small tapeworm" comes out of it (?sorry if it's not in english?), but you can everything to write down exactly.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    05-24-2013
    Location
    Liverpool, England
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Calculating time differences in 24 hour time when going past midnight

    Porucha Vevrku, Thank you very much. that has worked

    Thanks Guys.

+ 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. Replies: 5
    Last Post: 04-13-2017, 11:05 AM
  2. how to convert time if it's past midnight in military time
    By Jomejorada in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-15-2015, 07:50 AM
  3. [SOLVED] Text Time to Excel Format, Then Sort Time Past Midnight
    By BuntyMac in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-27-2014, 03:13 AM
  4. Calculating data within past 24 hour time period
    By WMUFlyboy in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-07-2014, 03:26 PM
  5. [SOLVED] Calculating time that goes past Midnight
    By jonvanwyk in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-27-2013, 04:14 PM
  6. Replies: 4
    Last Post: 01-11-2012, 07:59 PM
  7. [SOLVED] Calculating Time Past Midnight
    By Darren in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-13-2006, 11:03 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