title: EXCEL IF function logical test with date/time formats
body: <p>I've been working for a project to improve the managing of key performance indexes and I've hit a wall.</p>
  
  <p>Project: To evaluate whether the process(warehouse and quality) meets the deadline. When an Order comes in, the date/time is recorded and depending on the date/time, the deadline is different.</p>
  
  <p>For ease of explanation let B = Order received date/time (FORMAT DD.MM.YYYY HH.MM), X = Deadline (IN SAME FORMAT)</p>
  
  <p>Conditions: 
  1. If B is between 5.01 am and 1pm, then X = 5pm, else X = next day 9am
  2. If B is between sat 5am to 5am mon, then X = mon 9am.</p>
  
  <p>I have managed to figure out condition 1 but i have no idea how to incorporate condition 2 into my formula.</p>
  
  <p>Current formula</p>
  
  <p><code>=IF(AND(B&gt;DATE(YEAR(B),MONTH(B),DAY(B))+5/24,B&lt;=(DATE(YEAR(B),MONTH(B),DAY(B))+13/24)),DATE(YEAR(B),MONTH(B),DAY(B))+17/24,DATE(YEAR(B),MONTH(B),DAY(B))+24/24+9/24)</code></p>
  
  <p>I'm hoping the community can give me some insight on how to solve this enigma as i've been having plenty of luck finding solutions here.</p>