+ Reply to Thread
Results 1 to 7 of 7

Excel Formula to Calculate Time Span Between Different Time Range.

  1. #1
    Registered User
    Join Date
    08-16-2012
    Location
    London, England
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    6

    Excel Formula to Calculate Time Span Between Different Time Range.

    Hi;

    I am trying to calculate hours worked if time span fall between different time range.

    Range 1 Range 2 Range 3
    Start Time Finish Time Total Hours >14:00 and <16:00 >16:00 and <22:00 >22:00
    08:00 14:00 6 0 0 0
    08:00 15:00 7 1 0 0
    08:00 18:00 10 2 2 0
    10:00 17:00 7 2 1 0
    10:00 23:00 13 2 6 1
    12:00 02:00 14 2 6 4

    I can get the total hours worked by using the MOD Function = MOD(B2-A2,1)*24 but struggling on how to calculate number of hours if finish time falls between different time range.

    Any help will be much appreciated.

    Thanks
    Omer.

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

    Re: Excel Formula to Calculate Time Span Between Different Time Range.

    If you have total hours in C2 try this formula in D2 for hours between 14:00 and 16:00

    =MAX(0,MIN(B2,"16:00")-MAX(A2,"14:00"))*24

    and similar for 16:00 to 22:00

    =MAX(0,MIN(B2,"22:00")-MAX(A2,"16:00"))*24

    Then for hours after 22:00

    =MAX(0,MIN(B2+(B2<A2),1+(B2<A2))-MAX(A2,"22:00"))*24
    Audere est facere

  3. #3
    Registered User
    Join Date
    08-16-2012
    Location
    London, England
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    6

    Re: Excel Formula to Calculate Time Span Between Different Time Range.

    Thanks Daddylonglegs, much appreaciates. It works great.

    The only trouble i am having now is if it overlaps to next day, finding it difficult to get it to work.

    Following is what i am trying to achieve;


    Range 4 Range 5
    Start Time Finish Time Total Hours >23:00 and < 01:00 >01:00
    12:00 04:00 16 2 3


    Any help on this will be much appreciated.

    Thanks.

  4. #4
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,293

    Re: Excel Formula to Calculate Time Span Between Different Time Range.

    overlaps to next day
    use 28:00 hour with celformat h:mm you see 4:00
    You can calculate with >23:00
    Willem
    English is not my native language sorry for errors
    Please correct me if I'm completely wrong

  5. #5
    Registered User
    Join Date
    08-16-2012
    Location
    London, England
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    6

    Re: Excel Formula to Calculate Time Span Between Different Time Range.

    Thanks Popi, much appreciated. Your solution is great and It could do the job but I will need to create a helper column for it.

    Currently Data Entry are done on the Start and Finish Time so was hoping to find a formulae based solution rather than using a helper columns.

    Thanks.
    Omer.

  6. #6
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,293

    Re: Excel Formula to Calculate Time Span Between Different Time Range.

    You don't need a helper column.
    Attached Files Attached Files

  7. #7
    Valued Forum Contributor
    Join Date
    05-20-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2013
    Posts
    941

    Re: Excel Formula to Calculate Time Span Between Different Time Range.

    Please Login or Register  to view this content.
    Copy down, format as Number.

    Assumes no one will work past 0800 the following morning. Change as required.
    Last edited by jhren; 05-06-2015 at 08:30 AM.

+ 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] Need formula to calculate number of hours in a time span that are between 6PM and 6AM
    By gibson2503 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-05-2014, 06:13 PM
  2. Time and how to calculate three possible rates that span more than one day...
    By judefreeman in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 07-03-2014, 03:25 PM
  3. Replies: 3
    Last Post: 12-19-2013, 06:49 AM
  4. [SOLVED] A formula to countdown dates given a time span that is specific
    By poshbikerchick in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-05-2012, 06:07 AM

Tags for this Thread

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