+ Reply to Thread
Results 1 to 14 of 14

How to calculate hours when it goes after midnight.

  1. #1
    Registered User
    Join Date
    06-21-2014
    Location
    London
    MS-Off Ver
    10
    Posts
    4

    How to calculate hours when it goes after midnight.

    Hi,

    I'm having an issue I cannot solve since I'm not used to Excel. I created a spreadsheet to calculate hours done by staff, but the issue is that it's a nightclub and most hours are done from PM to AM, so if I put in a shift from 22:55 till 6:20am (for example) it won't calculate the proper hours. For that example it would show -16.58 hours, instead of 7.42 hours. What's the format code to use in this case when shifts goes past to the next day? I'm currently using '=(A-B)*24'.

    Cheers

  2. #2
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: How to calculate hours when it goes after midnight.

    If the start time is in A1 and the end time is in B1

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    format as h:mm
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: How to calculate hours when it goes after midnight.

    I suspect you are using to use the full date and time for shift start and end, instead of just time. Otherwise your formula would not return a negative number, it would fail with a result of "####" to fill the cell. The most straightforward and most accurate solution is to display the full date and time, and enter the correct date. Then your formula can stay the same.

    It is possible to do a kludgy formula that will work with your data, but I'm not sure my assumption about your data is correct. If start time is in column A and end time is in column B, then try this:

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


    If you attach your file (remove the names first) then I can see your data, and I can just modify your file for you, showing you both techniques.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Registered User
    Join Date
    06-21-2014
    Location
    London
    MS-Off Ver
    10
    Posts
    4

    Re: How to calculate hours when it goes after midnight.

    Hi,

    Thanks for the quick reply!

    I formatted as H:MM but your formula is getting me 7.25 hours for 22:55 till 06:20am and for some reason it's not multiplying the £/hour with the result properly now (giving £1.92 for 7.25 hours when it's multiplying by £6.35)
    I used the formula as '=E59-D59+(D59>E59)' where D59 is start time (22:55) and E59 is end time (6:20am).
    Am I doing something wrong here?

    Cheers

  5. #5
    Registered User
    Join Date
    06-21-2014
    Location
    London
    MS-Off Ver
    10
    Posts
    4

    Re: How to calculate hours when it goes after midnight.

    Here's an empty template I made, it has my formulas in it, if you could just edit the WEEK 1 grid as an example would be great, thanks!
    Attached Files Attached Files

  6. #6
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: How to calculate hours when it goes after midnight.

    Try this in F15

    Please Login or Register  to view this content.
    and then copy down.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: How to calculate hours when it goes after midnight.

    Quote Originally Posted by gps08 View Post
    Am I doing something wrong here?
    No, newdoverman neglected that you are multiplying by 24 to get hours. If you take his formula and multiply by 24

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


    it will work.

    Mine uses a different technique to produce the same result, and sktneer's uses yet a third technique to produce the same result, and the *24 are taking into account in both.

  8. #8
    Registered User
    Join Date
    06-21-2014
    Location
    London
    MS-Off Ver
    10
    Posts
    4

    Re: How to calculate hours when it goes after midnight.

    Thanks, both formulas work if I format the cell as number 1234,12 instead of h:mm.

  9. #9
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: How to calculate hours when it goes after midnight.

    When Start Time in D15 is 22:55 and Finish Time in E15 is 6:20 then the hours should be 7.25. So I think in F15, the formula should be like this.....

    Please Login or Register  to view this content.
    I have populated the values in Week1 grid.
    Attached Files Attached Files

  10. #10
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: How to calculate hours when it goes after midnight.

    This is what I was doing and gave the formula for.

    A
    B
    C
    D
    1
    22:55
    6:20
    7:25
    2
    =B1-A1+(A1>B1)
    3
    all times formatted as h:mm

  11. #11
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: How to calculate hours when it goes after midnight.

    @ newdoverman
    What if you have to multiply the hours so obtained with the wages per hour?

  12. #12
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: How to calculate hours when it goes after midnight.

    @ sktneer

    A
    B
    C
    D
    E
    F
    G
    1
    Start End Hours Rate/Hour Total
    2
    22:55
    6:20
    7:25
    25.75
    $190.98
    3
    =B2-A2+(A2>B2) =C2*E2*24
    4

  13. #13
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: How to calculate hours when it goes after midnight.

    @newdoverman
    hmmm.

  14. #14
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: How to calculate hours when it goes after midnight.

    That works just fine as long as long as gps08 doesn't mind seeing the hours in h:mm format, rather than a decimal number of hours as specified in the first post.

+ 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: 1
    Last Post: 06-03-2014, 06:28 PM
  2. Hours after midnight
    By maniootek in forum Excel General
    Replies: 12
    Last Post: 01-11-2014, 02:44 PM
  3. [SOLVED] Calculating hours worked beyond midnight
    By Boville in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-25-2012, 12:22 PM
  4. Hours in gnatt spanning midnight
    By r1ch1nxdcc in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-15-2009, 10:22 AM
  5. count hours past midnight
    By cojast in forum Excel General
    Replies: 3
    Last Post: 07-01-2008, 03:53 PM

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