Closed Thread
Results 1 to 9 of 9

Formula Needed - Calculate total hours that fall between a specific time period.

  1. #1
    Registered User
    Join Date
    07-05-2012
    Location
    Massapequa, NY
    MS-Off Ver
    Excel 2010
    Posts
    13

    Formula Needed - Calculate total hours that fall between a specific time period.

    Good afternoon All -
    This is my first time on this forum and I love the amount of information I have already learned.
    My question is:

    I have two colums - shift start and shift end.
    Shift Start Shift End
    0:00 05:00

    I need to calculate the hours between 00:00-04:00 and the amount of hours bewteen 04:00-06:00.
    For 00:00-0400 this example would show 4 hours
    For 04:00-06:00 this example would show 1 hour

    Please help as I am trying to calculate time shift premiums.

    Thank you.
    Jenny

  2. #2
    Forum Contributor
    Join Date
    03-15-2007
    Location
    AL, USA
    MS-Off Ver
    2007
    Posts
    174

    Re: Formula Needed - Calculate total hours that fall between a specific time period.

    Jenny,
    You should be able to simply subtract the values (End-Start).

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

    Re: Formula Needed - Calculate total hours that fall between a specific time period.

    Can the shift start before midnight, e.g. 20:00 to 05:00?

    To cover that possibility try this formula for 0:00 to 4:00

    =(B2<A2)*"4:00"+MIN(B2,"4:00")-MIN(A2,"4:00")

    and for 04:00 to 06:00

    =(B2<A2)*("6:00"-"4:00")+MEDIAN(B2,"4:00","6:00")-MEDIAN(A2,"4:00","6:00")

    That last one can be used generically for any period
    Audere est facere

  4. #4
    Registered User
    Join Date
    07-05-2012
    Location
    Massapequa, NY
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Formula Needed - Calculate total hours that fall between a specific time period.

    Hi and thank you for the help

    I tried the formula and its giving a response of 2:59 for 0000-0400 and 2:00 for 0400-0600



    Any ideas?

    Againt hank you for helping.
    Jenny

  5. #5
    Registered User
    Join Date
    07-05-2012
    Location
    Massapequa, NY
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Formula Needed - Calculate total hours that fall between a specific time period.

    Thank you mshale
    That formula gives me total hours but I need specific hours for specific time periods between the two times.

    Again thank you so much for trying to help.

    Happy Friday!

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,578

    Re: Formula Needed - Calculate total hours that fall between a specific time period.

    I double checked Daddy LL's formulas and they gave the correct answers (4:00 and 1:00 respectively). His formula (as written) assumes start time in A2 (0:00) and end time in B2 (5:00). Does that match your data?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  7. #7
    Registered User
    Join Date
    07-05-2012
    Location
    Massapequa, NY
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Formula Needed - Calculate total hours that fall between a specific time period.

    Hi Daddylonglegs -
    Please accept my apology as i copied the formula and of course somewhere did not check my orignal numbers on my file.

    Thank you so much- you are a LIFE SAVER!!!
    PS: I love this site - it is amazing!

  8. #8
    Registered User
    Join Date
    10-17-2019
    Location
    Stockholm
    MS-Off Ver
    365 ProPlus
    Posts
    70

    Re: Formula Needed - Calculate total hours that fall between a specific time period.

    If I would need to calculate the time that fall between 22:00 and 6:00 how should I modify the formula?

    Thank you

  9. #9
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,443

    Re: Formula Needed - Calculate total hours that fall between a specific time period.

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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