+ Reply to Thread
Results 1 to 6 of 6

If AND OR Help

  1. #1
    Registered User
    Join Date
    06-14-2005
    Location
    London
    MS-Off Ver
    2016
    Posts
    91

    If AND OR Help

    I having been trying, to no avail, to write a statement which takes into account the following variable

    Weekday is not 1 or 7 - i.e. Weekends

    That the time (broken into Hours and Minutes in seperate columns) is either:

    Greater than 07:30 but less than 08:30

    or

    Greater than 18:00 but less than 18:30

    Therefore if the weekday is 2-6 and either of the time statements are true I want Yes, if either the weekday is 1 or 7 or the time is outside of those times then No

  2. #2
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,118

    Re: If AND OR Help

    an example sheet would help
    I assume you are testing a date to get the weekday and its not a field

    if you use
    =weekday(A1,2)
    the ,2 uses a 1 for monday

    so now you need to know if the date is <6 for a weekday and not worry about a formula for 2-6

    =AND(WEEKDAY(A1,2)<6, OR(AND(TIME(HOUR(A1),MINUTE(A1),SECOND(A1))>=TIMEVALUE("18:00"),TIME(HOUR(A1),MINUTE(A1),SECOND(A1))<=TIMEVALUE("18:30")), AND(TIME(HOUR(A1),MINUTE(A1),SECOND(A1))>=TIMEVALUE("07:30"),TIME(HOUR(A1),MINUTE(A1),SECOND(A1))<=TIMEVALUE("08:30"))))

    =if( AND(WEEKDAY(A1,2)<6, OR(AND(TIME(HOUR(A1),MINUTE(A1),SECOND(A1))>=TIMEVALUE("18:00"),TIME(HOUR(A1),MINUTE(A1),SECOND(A1))<=TIMEVALUE("18:30")), AND(TIME(HOUR(A1),MINUTE(A1),SECOND(A1))>=TIMEVALUE("07:30"),TIME(HOUR(A1),MINUTE(A1),SECOND(A1))<=TIMEVALUE("08:30")))), "yes","NO")
    Wayne
    if my assistance has helped, and only if you wish to , there is an "* Add Reputation" on the left hand side - you can add to my reputation here

    If you have a solution to your thread - Please mark your thread solved do the following: >
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    06-14-2005
    Location
    London
    MS-Off Ver
    2016
    Posts
    91

    Re: If AND OR Help

    No i have the weekday already, here is an example worksheet (attached), in the Extended Day field I have typed what I would want to appear in each instance
    Attached Files Attached Files

  4. #4
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,118

    Re: If AND OR Help

    you can still use the date field A2
    and Add another nested IF to test if a weekend


    =IF(WEEKDAY(A2,2)>5,"Weekend", IF( AND(WEEKDAY(A2,2)<6, OR(AND(TIME(HOUR(A2),MINUTE(A2),SECOND(A2))>=TIMEVALUE("18:00"),TIME(HOUR(A2),MINUTE(A2),SECOND(A2))<=TIMEVALUE("18:30")), AND(TIME(HOUR(A2),MINUTE(A2),SECOND(A2))>=TIMEVALUE("07:30"),TIME(HOUR(A2),MINUTE(A2),SECOND(A2))<=TIMEVALUE("08:30")))), "YES","NO"))
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    06-14-2005
    Location
    London
    MS-Off Ver
    2016
    Posts
    91

    Thumbs up Re: If AND OR Help

    Fantastic that works perfectly, thanks for your knowledge/Assistance

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,856

    Re: If AND OR Help

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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