+ Reply to Thread
Results 1 to 12 of 12

Count Hours between Start Time & End Time but exclude Break Hours

  1. #1
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2019
    Posts
    4,127

    Count Hours between Start Time & End Time but exclude Break Hours

    Dear Sifu

    Help! I am trying to calculate total working hours after deducting break hours that one is entitled to.

    In below scenario, the person worked from 8:30 AM to 6:15 PM.

    He is entitled to lunch break because he has worked for 4.5 hours (8:30 AM to 1:00 PM) before the lunch break.

    He is also entitled to afternoon tea break because he has worked for 2 hours (2:00 PM to 4:00 PM) before the afternoon tea break.

    But he is not entitled to morning break because he has only worked for 1.5 hours (8:30 AM to 10:00 AM).

    In cell C6, I have this formula: "=SUMPRODUCT((C12:C14>=C3)*(C12:C14<=C4)*(D12:D14)/24)*24".

    How do I factor in the qualification for the break hours?

    Thanks in advance!
    Joseph

    Count Hours.png

  2. #2
    Registered User
    Join Date
    06-29-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    24

    Re: Count Hours between Start Time & End Time but exclude Break Hours

    Would it work to make a new column next to Min. Start Time to qualify which is the time he has qualified for? So: =IF(F12<C3,D12,0)
    That way if the start time is before the qualify time, you get the duration. Then in C6 you can add up just the breaks that have been qualified for?

  3. #3
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2019
    Posts
    4,127

    Re: Count Hours between Start Time & End Time but exclude Break Hours

    Thanks for your reply ocannon1... we have thousands of workers. The spreadsheet format in use is unlike the above. It will be difficult to incorporate your suggestion.

  4. #4
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    18,509

    Re: Count Hours between Start Time & End Time but exclude Break Hours

    Deleted by JeteMc
    Last edited by JeteMc; 08-22-2017 at 08:57 AM.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  5. #5
    Valued Forum Contributor Root_'s Avatar
    Join Date
    07-29-2017
    Location
    _
    MS-Off Ver
    2010+
    Posts
    507

    Re: Count Hours between Start Time & End Time but exclude Break Hours

    Maybe

    =SUMPRODUCT((F12:F14>=C3)*(C12:C14<=C4)*D12:D14)

  6. #6
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2019
    Posts
    4,127

    Re: Count Hours between Start Time & End Time but exclude Break Hours

    Oh ya... I could use back the same formula for the break hours qualification... but column F was created to showcase how the qualification works only.
    Supposed I don't have the column F, how could I adjust the formula?

    There is another problem, if the clock out time (End Time) is during the break hours or on the Start Time of the break hours, the total break hours would be incorrect.

    Take example below, the person clocked out at 4:15pm, so he only utilised 15 minutes for his afternoon tea break, not the full 30 minutes.

    How do I adjust that?

    Count Hours 2.png

  7. #7
    Valued Forum Contributor Root_'s Avatar
    Join Date
    07-29-2017
    Location
    _
    MS-Off Ver
    2010+
    Posts
    507

    Re: Count Hours between Start Time & End Time but exclude Break Hours

    Shouldn't the total break time be 1.75 hours?

    Here is a formula to try -- it doesn't use column F:

    =(C3<=C12-E12/24)*(C4>=C12)*MIN(D12,(C4-C12)*24)+(C3<=C13-E13/24)*(C4>=C13)*MIN(D13,(C4-C13)*24)+(C3<=C14-E14/24)*(C4>=C14)*MIN(D14,(C4-C14)*24)

    Or, if you prefer to have SUMPRODUCT:

    =SUMPRODUCT((C3<=C12:C14-E12:E14/24)*(C4>=C12:C14)*CHOOSE({1;2;3},MIN(D12,(C4-C12)*24),MIN(D13,(C4-C13)*24),MIN(D14,(C4-C14)*24)))
    Last edited by Root_; 08-22-2017 at 02:43 AM.

  8. #8
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2019
    Posts
    4,127

    Re: Count Hours between Start Time & End Time but exclude Break Hours

    Thanks, Root... both formulas worked very well!! However, I am looking for formulas that do not look at each line of breaks (we have more breaks than the 3 stated). it would be okay to retain column F.

  9. #9
    Valued Forum Contributor Root_'s Avatar
    Join Date
    07-29-2017
    Location
    _
    MS-Off Ver
    2010+
    Posts
    507

    Re: Count Hours between Start Time & End Time but exclude Break Hours

    Try this -- it takes in break rages (not individual lines):

    =SUMPRODUCT((C3<=C12:C14-E12:E14/24)*(C4>=C12:C14)*(D12:D14*(D12:D14<(C4-C12:C14)*24)+(C4-C12:C14)*24*(D12:D14>=(C4-C12:C14)*24)))

  10. #10
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2019
    Posts
    4,127

    Re: Count Hours between Start Time & End Time but exclude Break Hours

    Dear Root

    Formula #3 does not give the same results as Formula #1 and Formula #2...

    Count Hours 3.png

  11. #11
    Valued Forum Contributor Root_'s Avatar
    Join Date
    07-29-2017
    Location
    _
    MS-Off Ver
    2010+
    Posts
    507

    Re: Count Hours between Start Time & End Time but exclude Break Hours

    Quote Originally Posted by josephteh View Post
    Dear Root

    Formula #3 does not give the same results as Formula #1 and Formula #2...
    It's because you did not select the correct ranges for the new layout.

    The formula takes in the following ranges: break start time, break duration, and min hours worked.

    So, for the new layout, the formula should be:

    =SUMPRODUCT((C3<=$C$12:$C$14-$F$12:$F$14/24)*(C4>=$C$12:$C$14)*($E$12:$E$14*($E$12:$E$14<(C4-$C$12:$C$14)*24)+(C4-$C$12:$C$14)*24*($E$12:$E$14>=(C4-$C$12:$C$14)*24)))

  12. #12
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2019
    Posts
    4,127

    Re: Count Hours between Start Time & End Time but exclude Break Hours

    Oh ya.. copied wrongly.. the formula works perfect! Thanks!

+ 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] Timesheet that calcs time in, time out, lunch used, reg hours, ot hours, double hours
    By noobface in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 08-21-2021, 03:45 AM
  2. Replies: 2
    Last Post: 07-14-2015, 02:12 PM
  3. Replies: 10
    Last Post: 11-08-2014, 04:51 PM
  4. [SOLVED] Adding hours to start time - Business hours/holidays/weekends
    By Thunderer in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-21-2014, 01:09 PM
  5. [SOLVED] Calculate time for working hours when start time falls outside of working hours
    By SKDY_Beau in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-20-2014, 12:50 PM
  6. Replies: 0
    Last Post: 04-07-2011, 01:46 AM
  7. Replies: 1
    Last Post: 03-27-2006, 01:10 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