+ Reply to Thread
Results 1 to 3 of 3

Calculate number of hours within range

  1. #1
    Registered User
    Join Date
    03-12-2014
    Location
    dd
    MS-Off Ver
    Excel 2003
    Posts
    2

    Calculate number of hours within range

    Hello, I'm trying to figure out the simplest and most effective way to calculate if working hours are within specific range i.e.
    Employe starts his work
    21:00 ends at 7:00
    and I'd like to count how many hours are within 20-24; 24-4; 4-6; because different pay ratio.
    I tried with nested if, but succed only with 24-4 range.
    Please Login or Register  to view this content.
    PS. now I know I've used hour minute functions, when it's the same if you multiply it by 24

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

    Re: Calculate number of hours within range

    Hello miego

    For any period that doesn't start at midnight, end at midnight or cross midnight, like 4-6 you can use this formula

    =(B1<A1)*(6-4)+MEDIAN(B1*24,6,4)-MEDIAN(A1*24,6,4)

    for a period ending at midnight like 20-24 you can use this version:

    =(B1<A1)*4+MAX(B1*24,20)-MAX(A1*24,20)

    where 20 is the start time of the period and 4 is the length of it

    ....and for periods starting at midnight like 24-4 you can use this version

    =(B1<A1)*4+MIN(B1*24,4)-MIN(A1*24,4)

    where the 4s represent the end time of the period

    These formulas work for any shift length up to 24 hours, format result cells as number or general
    Audere est facere

  3. #3
    Registered User
    Join Date
    03-12-2014
    Location
    dd
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Calculate number of hours within range

    Thank you a lot. I also adopted this code to subtract unpaid break within this range.
    I would never thought it could be done with such simple functions.

+ 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. How to calculate number of hours
    By kobster in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-03-2014, 02:16 PM
  2. [SOLVED] How do I calculate the number of night hours worked
    By Somlal22 in forum Excel General
    Replies: 3
    Last Post: 08-17-2012, 07:18 AM
  3. calculate the number of working hours between two dates
    By sureshchinna_sb in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-29-2012, 09:57 AM
  4. Calculate minutes into hours in number format
    By ELTAMA in forum Excel General
    Replies: 3
    Last Post: 01-27-2012, 08:12 AM
  5. Calculate number of hours in timesheet
    By DMOfcMgr in forum Excel General
    Replies: 3
    Last Post: 04-26-2011, 07:18 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