+ Reply to Thread
Results 1 to 13 of 13

Formula help - If a time is between 2 times in excel

  1. #1
    Registered User
    Join Date
    03-14-2019
    Location
    Coventry, England
    MS-Off Ver
    2010
    Posts
    23

    Formula help - If a time is between 2 times in excel

    Good Afternoon All,

    Firstly, many thanks in advance for any help .

    What i am trying to achieve is show using the current time now(), how much time is remaining in a shift.

    However i have been having some issues with my between dates coming back with hashes (Due to shifts).

    So i have been trying to get this to work but my skills with excel formula are poor.

    nowtime is a cell using Now() formatted to time in HH:MM:SS

    This is what i have done so far for Early shift 06:00:00 - 14:00:00.

    Please Login or Register  to view this content.
    i was hoping for it to display a 0 or say "Not Current" if the time is not in the Early shift, instead of returning the hashes.
    but im honestly not sure how to lay out the formula.

    Kind regards

  2. #2
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: Formula help - If a time is between 2 times in excel

    I'm not the best with time but when you use now() you are getting the DATE and time regardless of how you format it.
    so the time alone for 06:00:00 is 0.25 when broken out as a number, for 14:00:00 it is 0.58. So how I would work it is more like
    =IF(AND(A2>=0.25,A2<=0.58),B3-shifts!J4,"")
    where A2 is your "now time" and input is like 07:15:15 instead of NOW() and then have what you want as the rest.
    hope that helps.
    EDIT: if you look at NOW() as a number (again, regardless of how you format it) it is 43725.31 which will never fall between those two parameters of 06:00:00 and 14:00:00 d/t the month part of it (9/17/2019 7:23:...)
    Last edited by Sam Capricci; 09-17-2019 at 07:25 AM.
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,428

    Re: Formula help - If a time is between 2 times in excel

    Try:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,428

    Re: Formula help - If a time is between 2 times in excel

    Or, alternatively,
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  5. #5
    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: Formula help - If a time is between 2 times in excel

    Perhaps

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    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.

  6. #6
    Registered User
    Join Date
    03-14-2019
    Location
    Coventry, England
    MS-Off Ver
    2010
    Posts
    23

    Re: Formula help - If a time is between 2 times in excel

    Afternoon,

    Many thanks for all your replies.

    TMS i have used your Second code and everything works perfect for the Early and Late Shift.

    However im having issue getting it to work for the night shift, i think its because its stepping over into the second day.

    22:00:00 - 6:00:00 (Night Shift hours)

    Is this something that can be easily fixed :/

    Kind regards

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,428

    Re: Formula help - If a time is between 2 times in excel

    Welcome to the forum

    Please attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,428

    Re: Formula help - If a time is between 2 times in excel

    Suspect you might need to split the check in two, before and after midnight.

  9. #9
    Registered User
    Join Date
    03-14-2019
    Location
    Coventry, England
    MS-Off Ver
    2010
    Posts
    23

    Re: Formula help - If a time is between 2 times in excel

    Afternoon,

    Many thanks for all your replies.

    TMS i have used your Second code and everything works perfect for the Early and Late Shift.

    However im having issue getting it to work for the night shift, i think its because its stepping over into the second day.

    22:00:00 - 6:00:00 (Night Shift hours)

    Is this something that can be easily fixed :/

    Kind regards

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,428

    Re: Formula help - If a time is between 2 times in excel

    Seems like an echo of post #6, ignoring post #7 and #8 in between.

    could do with seeing some examples.

  11. #11
    Registered User
    Join Date
    03-14-2019
    Location
    Coventry, England
    MS-Off Ver
    2010
    Posts
    23

    Re: Formula help - If a time is between 2 times in excel

    Afternoon TMS,

    I didnt repost it again.. im not sure why its done that.

    i am just in the process of making the file without the sensitive info.

    Kind regards

  12. #12
    Registered User
    Join Date
    03-14-2019
    Location
    Coventry, England
    MS-Off Ver
    2010
    Posts
    23

    Re: Formula help - If a time is between 2 times in excel

    Afternoon

    Please see file attached, i have placed a note in the file to show what im trying to achieve.

    Kind regards
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    03-14-2019
    Location
    Coventry, England
    MS-Off Ver
    2010
    Posts
    23

    Re: Formula help - If a time is between 2 times in excel

    Evening,

    I have tried a few methods even using the Mod() option but it doesnt seem to make a difference.

    Anyone else have any suggestions.

    kind regards

+ 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] Time Sheet Formula - different rate at different times
    By toxic27 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 04-10-2020, 08:08 AM
  2. Time Sheet Formula - different rate at different times
    By ZeRoo_ in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 07-24-2014, 10:15 AM
  3. Replies: 7
    Last Post: 04-09-2014, 09:25 AM
  4. If a search term can be found 1 time, 2 times 3 times 4 times 5 times
    By excelcandy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-10-2013, 09:57 PM
  5. Replies: 2
    Last Post: 05-31-2013, 04:37 AM
  6. Replies: 9
    Last Post: 04-24-2013, 11:48 PM
  7. Time formula to deduct two times
    By salvo69 in forum Excel General
    Replies: 5
    Last Post: 10-30-2012, 10:12 AM

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