+ Reply to Thread
Results 1 to 8 of 8

Calculating hours w/ ½ hour break

Hybrid View

  1. #1
    Registered User
    Join Date
    08-13-2010
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Calculating hours w/ ½ hour break

    hey excel noob here... thanks beforehand for any help you can give

    I'm trying to calculate hours worked while taking into consideration a half hour break if worked over 6 hours and a 1 hour break if worked over 8 hours.

    I've come up with 2 functions that kind of work...

    The first one works and automatically takes out the ½ hour break and 1 break, but it only works if your day starts and ends in the same day.

    Example... A1 being start time, B1 being end time, C1 being total hours

    A1 - 9:00 AM B1 - 5:00 PM C1 - 7.5

    for C1 the function is =(B1-A1)*24-IF((B1-A1)*24>8,1,IF((B1-A1)*24>6,0.5,0))

    Now where this function starts to go wrong is when you start at night and go into the morning.

    using the same function and a new scenario, I get

    A1 - 9:00 PM B1 - 4:00 AM C1 - -17.0

    what should be 6.5 hours worked is coming up as -17.

    Any help on why it's doing that and how I could fix it?

    Now I have a second function that works with both scenarios but it doesn't take out a break...

    A1 - 9:00 PM B1 - 4:00 AM C1 - 7:00

    the function in C1 is =IF(B1<A1,B1+1,B1)-A1

    Any help on getting a break into that function? Again thanks for any help you can give me, I just started messing around with excel and google has helped me with mostly everything I've needed so far but i've come to a roadblock with this particular function.

  2. #2
    Forum Contributor
    Join Date
    09-23-2008
    Location
    Mexico
    Posts
    200

    Re: Calculating hours w/ ½ hour break

    Try this:
    =IF(MOD(B2-A2,1)>8/24,MOD(B2-A2,1)-1/24,MOD(B2-A2,1)-0.5/24)

  3. #3
    Registered User
    Join Date
    08-13-2010
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Calculating hours w/ ½ hour break

    Not sure if you're allowed to curse on here but,

    ******* beautiful man


    thanks a lot, I really appreciate it.

    there's my answer
    Last edited by Three21Kobe; 08-13-2010 at 11:09 PM. Reason: misspelling

  4. #4
    Registered User
    Join Date
    08-13-2010
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Calculating hours w/ ½ hour break

    Hm, one problem with it though is if you work 4 hours it still takes out a ½ hour break.

    is there a way to only take out the break between 6-8?

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Calculating hours w/ ½ hour break

    Perhaps - assuming you want a decimal hours return:

    =24*MOD(B1-A1,1)-LOOKUP(24*MOD(B1-A1,1),{0,6,8},{0,0.5,1})

    If you prefer a Time output it can be adjusted quite easily - let us know.
    Last edited by DonkeyOte; 08-14-2010 at 03:36 AM.

  6. #6
    Registered User
    Join Date
    08-13-2010
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Calculating hours w/ ½ hour break

    Quote Originally Posted by DonkeyOte View Post
    Perhaps - assuming you want a decimal hours return:

    =24*MOD(B1-A1,1)-LOOKUP(24*MOD(B1-A1,1),{0,6,8},{0,0.5,1})

    If you prefer a Time output it can be adjusted quite easily - let us know.
    That works perfectly, thanks a ton.

  7. #7
    Forum Contributor
    Join Date
    09-23-2008
    Location
    Mexico
    Posts
    200

    Re: Calculating hours w/ ½ hour break

    Maybe this:
    =IF(MOD(B1-A1,1)<6/24,MOD(B1-A1,1),MAX(MOD(B1-A1,1)-1/24,MOD(B1-A1,1)-0.5/24))*24
    Last edited by Armando Montes; 08-14-2010 at 03:53 AM.

  8. #8
    Forum Contributor
    Join Date
    09-23-2008
    Location
    Mexico
    Posts
    200

    Re: Calculating hours w/ ½ hour break

    Didn't see DonkeyOte reply which is way better!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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