+ Reply to Thread
Results 1 to 11 of 11

finding # hrs between 2 date times

Hybrid View

  1. #1
    Forum Contributor TechRetard's Avatar
    Join Date
    06-14-2009
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    202

    Re: finding # hrs between 2 date times

    It is 7 days a week, however the start and end datetime may be outside the range of 8am to 8pm, and can be over multiple days...

    I could only get your formula to work within 1 day and within 8am to 8pm - but when i inputed 4/16/2010 08:00 to 4/18/2010 07:00 it returned "12:00" instead of 24

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: finding # hrs between 2 date times

    I believe this works, and expect it can be simplified:

    =(INT(A2) - CEILING(A1,1) + 1) * ("20:00"-"08:00") - MEDIAN(MOD(A1,1), "20:00", "8:00") + MEDIAN(MOD(A2,1), "20:00", "8:00")
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: finding # hrs between 2 date times

    Apologies on my part - I should have tested

    Another variation of shg's approach might be:

    =((INT(A2)-INT(A1))*("20:00"-"08:00"))-MEDIAN(MOD(A1,1),"20:00","8:00")+MEDIAN(MOD(A2,1),"20:00","8:00")

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: finding # hrs between 2 date times

    Another variation of shg's approach might be:
    Actually, vice versa -- mine was a variation of yours

  5. #5
    Forum Contributor TechRetard's Avatar
    Join Date
    06-14-2009
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    202

    Re: finding # hrs between 2 date times

    nice sgh.. i think that will do it

    i'll keep testing and let you know if I encounter any weird numbers but so far so good

    rock on!

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: finding # hrs between 2 date times

    I recommend DO's -- it's more compact and easier to understand.

  7. #7
    Forum Contributor TechRetard's Avatar
    Join Date
    06-14-2009
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    202

    Re: finding # hrs between 2 date times

    Donkey that seems to work as well

    nice job guys, i've been slaving over this for hours...much appreciated

+ 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