+ Reply to Thread
Results 1 to 8 of 8

I need a formula to count how many hours between 18:00 and 6:30, during 2 given times

  1. #1
    Registered User
    Join Date
    02-03-2013
    Location
    Curacao
    MS-Off Ver
    Excel 2007
    Posts
    15

    I need a formula to count how many hours between 18:00 and 6:30, during 2 given times

    Hi guys, I need to bother you once again

    Say I have 2 times e.g
    D8= 14:00
    E8= 22:00

    I need a formula to count how many hours between D8 and E8 is between 18:00 and 6:30

    In this example its 4 hours (18:00 till 22:00)

    If D8 was 19:00
    and E8 was 5:00,

    then the formula result should be 10 hours (19:00 till 5:00)

    another example
    If D8 was 4:00
    and E8 was 11:00

    formula result should be 2.5 hours (4:00 till 6:30)

    I would also appreciate if you can explain the formula, so I can learn from it.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: I need a formula to count how many hours between 18:00 and 6:30, during 2 given times

    In your example...
    If D8 was 19:00
    and E8 was 5:00

    i presume you mean 5:00 am the next day?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: I need a formula to count how many hours between 18:00 and 6:30, during 2 given times

    deleted my duplicate post

  4. #4
    Registered User
    Join Date
    02-03-2013
    Location
    Curacao
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: I need a formula to count how many hours between 18:00 and 6:30, during 2 given times

    Yes FDibbins.....19:00 is 7 O' clock PM.......5:00 is 5 O'clock Am the next day

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

    Re: I need a formula to count how many hours between 18:00 and 6:30, during 2 given times

    It's easier to claculate the hours during a period which doesn't pass through midnight, so to get hours 06:30 to 18:00 you can use this formula

    =((E8<D8)*("18:00"-"6:30")+MEDIAN(E8,"6:30","18:00")-MEDIAN(D8,"6:30","18:00"))*24

    so to get 18:00 to 06:30 hours you can sinply subtract that from the total hours, i.e.

    =(MOD(E8-D8,1)-(E8<D8)*("18:00"-"6:30")-MEDIAN(E8,"6:30","18:00")+MEDIAN(D8,"6:30","18:00"))*24
    Audere est facere

  6. #6
    Registered User
    Join Date
    02-03-2013
    Location
    Curacao
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: I need a formula to count how many hours between 18:00 and 6:30, during 2 given times

    Daddylonglegs.....
    Can you please explain what exactly both of those formula is doing.
    I don't wanna just copy paste.
    Last edited by LionelSpratt; 02-11-2013 at 11:58 AM.

  7. #7
    Registered User
    Join Date
    10-05-2012
    Location
    Malaysia
    MS-Off Ver
    Excel 2019
    Posts
    74

    Re: I need a formula to count how many hours between 18:00 and 6:30, during 2 given times

    Hi LionelSpratt

    Maybe if you have the date stated as well, it will be more clear?
    For example, 2/13/2013 19:00 to 2/14/2013 5:00.

    A2=2/13/2013 19:00 --> Start Date & Time
    B2=2/14/2013 5:00 --> End Date & Time

    =TEXT(B2-A2,"[h]:mm")

    You will get 10hours as the result.

    Is this what you need? Hope it helps (^-^)

  8. #8
    Registered User
    Join Date
    02-03-2013
    Location
    Curacao
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: I need a formula to count how many hours between 18:00 and 6:30, during 2 given times

    Hikari......
    Thanks for your effort, but it doesn't give me what I need.

    The formula that Daddylonglegs posted works perfectly

    I just don't understand the formula
    And I want to understand so next time i can do it myself, or adapt it if I have to.

    I hope someone can explain what the formula does exactly

+ 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