+ Reply to Thread
Results 1 to 7 of 7

Count time after midnight

  1. #1
    Registered User
    Join Date
    06-27-2008
    Location
    Fort Worth, Texas
    Posts
    7

    Count time after midnight

    I would like to count how may people are on duty each hour. If I use this format =IF(AND($a1<=BR$4,$b1>BR$4),1

    A= start time
    B= end time
    BR= time of day ( for instance 1600or 1700)

    with the shift of 1600-0230

    all works fine until I get to the overnight shift were the end time is 0230 or 0330... and it registers "false" because b1< than BR4 (0230 is less than 1700 and will not count this as a valid time slot.

    Can someone please offer a suggestion that would cover regular and overnight shifts? Thanks

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

    Re: Count time after midnight

    Try like this

    =IF(($a1<=BR$4)+($b1>BR$4)+($a1>$b1)=2,......

  3. #3
    Registered User
    Join Date
    06-27-2008
    Location
    Fort Worth, Texas
    Posts
    7

    Re: Count time after midnight

    shift is 1800-0230
    a=1800
    b=0230
    br=1700

    =IF(($a1<=BR$4)+($b1>BR$4)+($a1>$b1)= 1

    br=1800
    =IF(($a1<=BR$4)+($b1>BR$4)+($a1>$b1)= 2

    I can not find a consistant format that would cover the hours they work and count at 1 or 2 and then for hours they don't work to count as 0. Thanks

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

    Re: Count time after midnight

    Sorry, perhaps I misinterpreted your requirement, I thought you wanted to base an IF statement on that test. If you want to return a 1 when the BR time is between A1 and B1, a zero otherwise, just use this formula

    =(($a1<=BR$4)+($b1>BR$4)+($a1>$b1)=2)+0

    so If a1 = 18:00 and B1 = 02:30 then 19:00 or 01:00 in BR4 will give a 1 but 03:00 will give a zero, is that what you need?

    Of course the formula still works if your shift doesn't pass through midnight....

  5. #5
    Registered User
    Join Date
    06-27-2008
    Location
    Fort Worth, Texas
    Posts
    7

    Re: Count time after midnight

    Worked great thanks.

  6. #6
    Registered User
    Join Date
    03-08-2004
    Posts
    12

    Re: Count time after midnight

    I don't want to hijack this thread but I also didn't want to start a new one for the same type problem. If I should, moderator please delete this response and I will create a new thread.

    I was not able to get the formula to work as described, but perhaps I am not looking at it correctly. I have attached a sample workbook of what I am trying to accomplish and would appreciate some tweaking of the formula.
    The formula works for shifts between 0000 and 2400 but does not when crossing over midnight.
    I would also like to understand the logic behind the formula. I know it has to do with T/F conditions, but I'm confused about the "2" in the formula.

    Thanks,
    TC
    Attached Files Attached Files

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

    Re: Count time after midnight

    Please start your own thread.
    Entia non sunt multiplicanda sine necessitate

+ 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