+ Reply to Thread
Results 1 to 13 of 13

Evaluating times that cross midnight divide

  1. #1
    Forum Contributor
    Join Date
    07-19-2019
    Location
    Illinois, USA
    MS-Off Ver
    365
    Posts
    170

    Evaluating times that cross midnight divide

    Please see sample attached. On the "Roster" tab you put in your base schedule, then the "breakdown" tab gives you a visual across a 24-hour timeframe.

    The formula I'm using works, except when the span of time between the "Start" and "End" cross midnight divide. Example:

    Start = 12:00
    End = 18:00
    Formula works fine

    But

    Start = 18:00
    End = 04:00
    Formula no longer works fine, only working correctly on the hours of 01:00, 02:00, 03:00, and 04:00.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,152

    Re: Evaluating times that cross midnight divide

    To save me reverse engineering it, please explain in words what the formula needs to do. There's probably an easier way.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Contributor
    Join Date
    07-19-2019
    Location
    Illinois, USA
    MS-Off Ver
    365
    Posts
    170

    Re: Evaluating times that cross midnight divide

    It's evaluating if the time in D2 falls between the "Start Time" in B3 and "End Time" in C3. If it does fall between it, it executes the xlookup. If it doesn't, it should return blank.

    I thought I fixed the midnight divide issue with the
    Please Login or Register  to view this content.
    but that isn't working

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,152

    Re: Evaluating times that cross midnight divide

    See if this works for you:

    =IF(AND($C3>$B3,D$2>=$B3,D$2<=$C3),XLOOKUP($A3,INDEX(Roster,0,MATCH("Name",Roster[#Headers],0)),INDIRECT("Roster["&$B$1&"]")),IF(AND(D$2<=$B3,D$2>=$C3),XLOOKUP($A3,INDEX(Roster,0,MATCH("Name",Roster[#Headers],0)),INDIRECT("Roster["&$B$1&"]")),""))

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,152

    Re: Evaluating times that cross midnight divide

    No - that's not working - sorry.

  6. #6
    Forum Contributor
    Join Date
    07-19-2019
    Location
    Illinois, USA
    MS-Off Ver
    365
    Posts
    170

    Re: Evaluating times that cross midnight divide

    Unfortunately, no, it is not working, though it did change up the results a bit. Images below

    This first image is the result of the formula you suggested. Like the original formula, this one works just fine as long as the "before" and "after" times do not cross midnight.
    Attachment 884684

    This second image is the desired final result, showing "HA1" and "HA2" active between the hours of 18:00 and 04:00
    Attachment 884685

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,152

    Re: Evaluating times that cross midnight divide

    Try again:

    =IF(AND($C3>$B3,D$2>=$B3,D$2<=$C3),XLOOKUP($A3,INDEX(Roster,0,MATCH("Name",Roster[#Headers],0)),INDIRECT("Roster["&$B$1&"]")),IF(AND($C3<$B3,OR(D$2>=$B3,D$2<=$C3)),XLOOKUP($A3,INDEX(Roster,0,MATCH("Name",Roster[#Headers],0)),INDIRECT("Roster["&$B$1&"]")),""))

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,152

    Re: Evaluating times that cross midnight divide

    Slightly shorter:

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    07-19-2019
    Location
    Illinois, USA
    MS-Off Ver
    365
    Posts
    170

    Re: Evaluating times that cross midnight divide

    I had an "ah ha!" moment just now... this formula works as intended. Apologies for using up your time
    Please Login or Register  to view this content.

  10. #10
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,674

    Re: Evaluating times that cross midnight divide

    Please Login or Register  to view this content.
    Try this formula with an extended table

    I find the table not logic

    Are columns T:AA thursday or friday?
    Attached Files Attached Files
    Last edited by popipipo; 12-11-2024 at 12:55 PM.
    Willem
    English is not my native language sorry for errors
    Please correct me if I'm completely wrong

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,152

    Re: Evaluating times that cross midnight divide

    @PrimePorkchop

    Did you see posts #7 and #8?

    Glad to have helped.

    If you have not already done so, remember that you can reward anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of each of those who offered help.
    Last edited by AliGW; 12-12-2024 at 03:47 AM. Reason: Redacted for clarity.

  12. #12
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,674

    Re: Evaluating times that cross midnight divide

    Yes i have seen it
    But, like i said I find the table not logic.

    And what is wrong with another option?

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,152

    Re: Evaluating times that cross midnight divide

    All options are valiid!

    I've amended my post for clarity - the question wasn't aimed at you. Sorry for the confusion.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Calculating the number of OT hours between two times from times that cross midnight.
    By Maryse Roy in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-11-2023, 06:44 PM
  2. [SOLVED] Calculating times between before midnight and after midnight
    By FvdF in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 10
    Last Post: 10-16-2021, 05:47 AM
  3. [SOLVED] Calculate how many hours between two times are before midnight and after midnight
    By annazet in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-05-2019, 09:47 AM
  4. Elapsed times that cross midnight.
    By FayY in forum Excel General
    Replies: 4
    Last Post: 09-21-2019, 01:24 PM
  5. [SOLVED] Looking for MAX formula when times span or cross midnight
    By Rex411 in forum Excel General
    Replies: 6
    Last Post: 02-16-2016, 08:22 PM
  6. [SOLVED] Difference between two times - avoiding ###### for times that span midnight
    By Abarency in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-07-2015, 01:15 PM
  7. getting the difference bewtween two times accounting for midnight cross over
    By superchew in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-12-2013, 11:30 PM

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