+ Reply to Thread
Results 1 to 5 of 5

How to count working hours between two different periods?

  1. #1
    Registered User
    Join Date
    03-02-2008
    Posts
    3

    Question How to count working hours between two different periods?

    Dear Excelers,

    How to count working hours between two different periods?

    For example:

    I am working in overtime claim form; where I have two different periods, for the reason that every period has a different rate:
    1) Period (1) 4:00-21:00, at the rate of 125%.
    2) Period (2) 21:00-4:00, at the rate of 150%.


    Problem:

    Where A2 (On Overtime), and B2 (Off Overtime): A2=20:00, & B2=5:00.

    An employee claim over time from: 20:00-5:00, that falls into two periods:
    1) From 20:00-21:00, Period (2).
    2) From 21:00-4:00, Period (1).
    3) From 4:00-5:00, Period (2).

    C is Period (1) and D is Period (2).

    I want to be: C=7, and D=2.

    Is it possible in Excel?!

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,756
    To accommodate any shift lengths up to 24 hours try these formulas

    D2

    =((A2>B2)*MEDIAN(0,B2-1/6,17/24)+MAX(0,MIN(7/8,B2+(A2>B2))-MAX(1/6,A2)))*24

    C2

    =MOD(B2-A2,1)*24-D2

    format both cells as number

    The values 1/6, 7/8 and 17/24 in the D2 formula represent, respectively, the start of period, 04:00, the end of period, 21:00 and the length of period, 17:00
    Last edited by daddylonglegs; 03-02-2008 at 08:44 AM.

  3. #3
    Registered User
    Join Date
    03-02-2008
    Posts
    3

    Thumbs up

    Thank you so much..

    it works...


  4. #4
    Registered User
    Join Date
    03-02-2008
    Posts
    3
    Dear daddylonglegs,

    This formula does not work well, because when I enter an overtime period A2: 16:00, B2: 18:00, 2 hours falls in D2 - period (2) – rather than in C2 - period (1).

    Note that:
    1) Period (1) 4:00-21:00, at the rate of 125%.
    2) Period (2) 21:00-4:00, at the rate of 150%.

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,756
    But you also said in your original post that if A2 = 20:00 and B2 = 05:00 that C2 =7 and D2 = 2, if you want that the other way round then make the formulas

    C2

    =((A2>B2)*MEDIAN(0,B2-1/6,17/24)+MAX(0,MIN(7/8,B2+(A2>B2))-MAX(1/6,A2)))*24

    D2

    =MOD(B2-A2,1)*24-C2

+ 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