title: Find current time between two fields in Oracle
body: <p>I have a situation where i need to raise an event everyday between 23:00 hrs to next day 01:00 hrs. 
  My table has a data of date which will look like:</p>
  
  <pre><code>Start date          | EndDate
  31-05-2016 23:00:00 | 01-06-2016 01:00:00
  </code></pre>
  
  <p>Already the database is designed like this and applications are live. Now, i tried getting the data using <code>BETWEEN</code> statement, but, nothing works how i need since the ENDDate is next day morning.</p>
  
  <p>Could someone tell how to extract this data correctly.</p>
  
  <p>My <code>ORACLE</code> Query</p>
  
  <pre><code> SELECT COUNT(*) INTO P_OUTPUT FROM MAINTENANCE_LOG WHERE      
   NVL(RECCURING_TYPE,'O')='D' AND ACTIVE_STATUS='Y' AND
   TO_CHAR(SYSDATE,'HH24MISS') BETWEEN TO_CHAR(START_DATE,'HH24MISS') AND TO_CHAR(END_DATE,'HH24MISS');
  </code></pre>
  
  <p>I tried converting this to date again, but it also does not work with the EndDate.</p>
  
  <p>Update:
  In my requirement I need only to check whether the current time is between the startdate or enddate time. I need to run this query everyday and it should do an activity between 23:00 and 1:00 of each day. </p>
  
  <p>Note: If I run the query of <code>Sysdate between startdate and enddate</code> on 31-05-2015 i will get true/false. But, if I run this next day at night I will only get false since the EndDate is already over. So, I cant use the normal between date query. </p>