title: PL/SQL Check if SYSDATE is between two DATETIMES "HH24:mi"
body: <p>I'm trying make a function to check if my sysdate is between 2 datas on the HH24:mi. If this is true then it needs to return 1 if its not return 0.</p>
  
  <p>I tried this one but without succes: <a href="https://stackoverflow.com/questions/23398632/check-if-current-date-is-between-two-dates-oracle-sql">Check if current date is between two dates Oracle SQL</a></p>
  
  <p>Here is the code I used:</p>
  
  <pre><code>create or replace FUNCTION WinkelOpen(winkelID Number)
    RETURN NUMBER
  IS
    CURSOR c_tijden_t(v_temp_winkelID IN NUMBER, v_temp_dag IN VARCHAR2) IS
          SELECT * FROM Openingstijd
          WHERE winkel_id = v_temp_winkelID
          AND dag = v_temp_dag;
  
    TYPE a_array_days IS VARRAY(7) OF VARCHAR2(2);
      v_dagen a_array_days := a_array_days('ma', 'di', 'wo', 'do', 'vr', 'za', 'zo');    
  
    v_temp_suc  NUMBER;
    v_isClosed Number(1,0) := 0;
  
  
  BEGIN
    FOR i IN c_tijden_t(winkelID, v_dagen(to_char (SYSDATE, 'D')-1)) LOOP
  
      select * INTO v_temp_suc from dual 
      WHERE trunc(sysdate) 
      BETWEEN TO_DATE(i.open, 'HH24:mi') 
      AND TO_DATE(i.gesloten, 'HH24:mi');
  
      --if v_temp_suc is 0 then keep looping
      --else v_isClosed = 1 break loop
  
      END LOOP;
      RETURN v_isClosed;
  END WinkelOpen;
  </code></pre>