+ Reply to Thread
Results 1 to 10 of 10

To check if a time value is between to times across midnight

  1. #1
    Registered User
    Join Date
    07-17-2019
    Location
    Sweden
    MS-Off Ver
    Version 1906 MS Excel
    Posts
    34

    To check if a time value is between to times across midnight

    Hi! I have been using an if function to check if a time value is between two other times. The formula I've been using is =if(and(B4>=C5;B4<=C6);"true";"false") with C5 containing the start value, C6 the end value and B4 the time value that I want to check. So for example, if I want to know if the 00.10 (which is B4 in this case) falls between 23.40 (which is C5 in this case) and 01:00 (C6 in this case), it says false but I want it to say true. Anyone that knows an easy formula to fix this?
    Last edited by helloxxx; 07-22-2019 at 05:20 AM.

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

    Re: To check if a time value is between to times across midnight

    Try this:

    =MOD(B1-A1,1)

    where A1 is the start time and B1 the finish time.
    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.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    07-17-2019
    Location
    Sweden
    MS-Off Ver
    Version 1906 MS Excel
    Posts
    34

    Re: To check if a time value is between to times across midnight

    Not sure how you mean, to put the mod(B1-A1,1) in the if function or just like you wrote it? Beacuse when I type in what you wrote I only get 01:00 back.

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

    Re: To check if a time value is between to times across midnight

    Did you adapt it to suit your cells?

    =MOD(C6-C5,1)

    What is your expected outcome?

    Can you attach a sample workbook? It's not entirely clear what you are trying to achieve.

  5. #5
    Registered User
    Join Date
    07-17-2019
    Location
    Sweden
    MS-Off Ver
    Version 1906 MS Excel
    Posts
    34

    Re: To check if a time value is between to times across midnight

    Sorry, I edited my first post to clarify. My expected outcome is for the formula to say "true" when I check if a value like 00:10 is between two values that are across midnight, for example if 00:10 is between 23.40 and 01.00. But it says false. Tried to attach a workbook but it doesn't work.. maybe you understand better now?

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,866

    Re: To check if a time value is between to times across midnight

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

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

    Re: To check if a time value is between to times across midnight

    You've been asked for a workbook - instructions above in post #6.

    Your duplicate thread has been closed.

  8. #8
    Registered User
    Join Date
    07-17-2019
    Location
    Sweden
    MS-Off Ver
    Version 1906 MS Excel
    Posts
    34

    Re: To check if a time value is between to times across midnight

    Here is a sample excel file, let me know if there's something you dont understand!
    Attached Files Attached Files

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,866

    Re: To check if a time value is between to times across midnight

    Bumping for visibility.

    Please be patient.

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

    Re: To check if a time value is between to times across midnight

    If you have further queries around this problem, post them here.

    You have now tried three times to open duplicate threads, which is not allowed. Please do not open any further threads on this same issue - continue here in this thread.

+ 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. Replies: 12
    Last Post: 11-11-2018, 08:41 AM
  2. [SOLVED] Want to extract time before and after midnight for a time range that spans midnight
    By schurchill39 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-26-2018, 04:18 PM
  3. How Can I Work Out a time Before Midnight and After Midnight???
    By ArmandDataCube in forum Excel General
    Replies: 7
    Last Post: 08-23-2017, 06:13 PM
  4. [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
  5. # of times midnight is crossed between date and time ranges
    By thuddleston11 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-12-2013, 08:03 AM
  6. Replies: 3
    Last Post: 07-26-2012, 10:50 AM
  7. Replies: 4
    Last Post: 11-28-2010, 08:18 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