+ Reply to Thread
Results 1 to 4 of 4

using TIME in an IF(AND function

  1. #1
    Registered User
    Join Date
    05-12-2016
    Location
    Newcastle, England
    MS-Off Ver
    2010
    Posts
    10

    using TIME in an IF(AND function

    Hi All,

    I'.m stuck and wondering if anyone can help. Essentially i have the time a job was requested. Depending on when in the day that was dictates how long we have to complete it. Basically if we receive it between 20:00 and 08:00 the following day its a 4 hour SLA, if we receive it on a Saturday or Sunday its a 4 hour SLA, all other times its a 3 hour SLA.

    I then need to work out how long it took us to do the job and whether that falls within the right time bands.

    So i have my date of request which i then change the format to give me the actual Day of the Week, then the time the job was received. This is formatted as TIME and shows as HH:MM:SS

    05/06/2016 SUNDAY 20:25:00

    From this i've tried to use the following formula (ECO being the job type code). I've included blank spaces after Sunday as it only seems to work when there are 9 characters in this field. I'm assuming that's because Wednesday is 9 characters long, so all other days get padded with space?

    =IF(AND(AN65="ECO",M65="SUNDAY "),"4 Hours SLA",IF(AND(AN65="ECO",M65="SATURDAY "),"4 Hours SLA",IF(AND(P65>=TIME(20,0,0),P65<=TIME(8,0,0)),"4 Hour SLA","3 Hour SLA"))))

    So i've tried each component part on its own, IF(AND(AN65="ECO",M65="SUNDAY "),"4 Hours SLA", gives me the answer i need as does IF(AND(AN65="ECO",M65="SATURDAY "),"4 Hours SLA", at first i just had everything else showing as "3 Hour SLA but that's not enough i need to build the time factor in there as well. I've tried showing the time as 20:00:00 and 20,0,0 as above but it still doesn't work. in the example above when i remove Sunday from the spreadsheet to test it it tells me that 20:25:00 would be a 3 hour SLA which is wrong. What am i doing wrong?

    This is also causing me issues on the next stage of the spreadsheet as having worked out how long it took us to reach the job i then need to see whether we hit SLA for which i've used =IF(AND(AT65="4 Hours SLA",AU65>="04:00:00"),"SLA Fail",IF(AND(AT65="3 Hours SLA",AU65>="03:00:00"),"SLA FAIL",""))) Again this isn't working but i don't know if that's because the first stage is wrong so will not produce output on the second formula or if i also have issues here.


    Any help very much appreciated!!!

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,728

    Re: using TIME in an IF(AND function

    The time in P65 can't be BOTH >20:00:00 AND <8:00:00 at the same time - change the AND to OR. Also, you can simplify the first part like this:

    =IF(AND(AN65="ECO",WEEKDAY(D65,2)>5),"4 Hours SLA",IF(OR(P65>=TIME(20,0,0),P65<=TIME(8,0,0)),"4 Hour SLA","3 Hour SLA")))

    I've assumed that column D contains the date - change the item in red to suit.

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    05-12-2016
    Location
    Newcastle, England
    MS-Off Ver
    2010
    Posts
    10

    Re: using TIME in an IF(AND function

    Thanks Pete, loving the simplified bit, makes it look much tidier but i still don't think its working. The bit about WEEKDAY(D65,2)>5), what does this do? I'm assuming from something like 05/06/16 it looks at the 05 bit but i don't understand what the >5 does?

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,728

    Re: using TIME in an IF(AND function

    The WEEKDAY function works on a date and returns the day of the week as a number. With the second parameter set to 2, it returns 1 for Monday, 2 for Tuesday etc. so weekends are either 6 or 7 (i.e. greater than 5).

    Hope this helps.

    Pete

+ 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] elapse time function ( time entered with no colon).
    By jackm1249 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-23-2014, 02:09 PM
  2. Replies: 1
    Last Post: 03-28-2014, 12:45 PM
  3. IF function to work out Ordinary hours, Time 1/2 and Double time!!
    By Jazzy2009 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-13-2014, 11:32 PM
  4. [SOLVED] IF function: Early/On Time/Late Time vs. set window of time
    By hclark579 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-21-2014, 05:37 PM
  5. [SOLVED] Extracted time from date/time field does not flag on =IF(TIME function.
    By Vlad717 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-09-2013, 03:29 PM
  6. Date/Time Function in Excel (Day/Month/Year & time)
    By tortuga32 in forum Excel General
    Replies: 19
    Last Post: 12-14-2011, 02:00 AM
  7. Replies: 4
    Last Post: 03-23-2010, 12:44 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