+ Reply to Thread
Results 1 to 5 of 5

Time calculations when going over the midnight

  1. #1
    Forum Contributor ABSTRAKTUS's Avatar
    Join Date
    04-18-2010
    Location
    England
    MS-Off Ver
    Win10 Excel 2016
    Posts
    609

    Time calculations when going over the midnight

    Hi all,

    I can't get my head round how to make formula kind of "ignore" midnight point. I'm trying to calculate staff availability for the 24 hours period (7:00 am to 7:00 am). Wrote a formula and it works until it reaches midnight. Assume you have col B with No. of heads, col C - time staff available from, col D - time staff available to. In F2 and going across I have a time table starting at 7:00 all the way through to the next 7:00 am.

    This is the formula I'm using:
    Please Login or Register  to view this content.
    The formula returns me 0 if "from - to" is overlaping midnight.
    Any ideas gurus?

    See attached...
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Time calculations when going over the midnight

    Hi,

    How about in F4

    =IF(AND($C4<=F$2,$D4>F$2),$B4,IF(ROUND(F$2,6)>=ROUND($C4,6),$B4,0))

    copied to all the range in question
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Contributor ABSTRAKTUS's Avatar
    Join Date
    04-18-2010
    Location
    England
    MS-Off Ver
    Win10 Excel 2016
    Posts
    609

    Re: Time calculations when going over the midnight

    Hi and thanks for a prompt response. I have applied your formula and faced another issue. Now starting times look alright, but they all end at the end of table. Lets say I have 20 staff available from 23:00 to 4:00, formula is resulting 23:00 start and 7:00 finish.

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

    Re: Time calculations when going over the midnight

    Try this version in F3 copied across and down

    =IF(($C3<=F$2)+($D3>F$2)+($C3>$D3)=2,$B3,0)
    Audere est facere

  5. #5
    Forum Contributor ABSTRAKTUS's Avatar
    Join Date
    04-18-2010
    Location
    England
    MS-Off Ver
    Win10 Excel 2016
    Posts
    609

    Re: Time calculations when going over the midnight

    Hi mate,

    Yes, that did a trick. Good job. Thanks!

+ 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