+ Reply to Thread
Results 1 to 4 of 4

Hours between specific times

  1. #1
    Registered User
    Join Date
    03-31-2012
    Location
    Nottingham
    MS-Off Ver
    OFFICE 365
    Posts
    17

    Hours between specific times

    Hello,

    I am trying to create a formula to work out the number of hours between specific times. This is to calculate a shift allowance payment.

    Any hours worked between 20:00 and 06:00 will be enhanced by a shift allowance. I need a spreadsheet where the user enters the start and end of their shift, the formula should then work out if this shift qualifies for the allowance and calculate the number of hours to be enhanced:

    e.g.

    Start: 31/03/2012 22:00
    End: 01/04/2012 07:00
    Total hours: 9
    Enhanced: 8

    I haven't used excel for a long time and just cant begin to think how you would do this.
    Thanks

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,719

    Re: Hours between specific times

    If you have start time/date in A2 and end time/date in B2 then you can get total hours with this formula

    =(B2-A2)*24

    ....and then hours between 20:00 and 06:00 only with this one

    =(B2-A2)*10+(MOD(B2,1)-MOD(A2,1))*14-MEDIAN(MOD(B2,1)*24,6,20)+MEDIAN(MOD(A2,1)*24,6,20)
    Audere est facere

  3. #3
    Registered User
    Join Date
    03-31-2012
    Location
    Nottingham
    MS-Off Ver
    OFFICE 365
    Posts
    17

    Re: Hours between specific times

    Thanks for that, it works brilliantly.
    If ever the allowance hours were to change say 21:00 - 06:00, which part of the formula would I amend?
    Many thanks for your help.

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,719

    Re: Hours between specific times

    You'd need to change the 20s and 6s and also 14 and 10 (10 being the number of hours between 20:00 and 06:00), so for 21:00 to 06:00 change to

    =(B2-A2)*9+(MOD(B2,1)-MOD(A2,1))*15-MEDIAN(MOD(B2,1)*24,6,21)+MEDIAN(MOD(A2,1)*24,6,21)

+ 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