title: Optimizing SQL Query and Dynamically using current date
body: <p>I am trying to optimize a simple SQL query and was wondering if anyone has any suggestions. I am developing using Oracle SQL Developer (which I don't like) on an Oracle 11g database. The query I am using is:</p>
  
  <pre><code>SELECT count(*) 
  FROM my_table 
  WHERE my_date
  BETWEEN TO_DATE('2012-5-09T05.00.00','YYYY-MM-DD"T"HH24:MI:SS') 
  AND TO_DATE('2012-5-10T04.59.59','YYYY-MM-DD"T"HH24:MI:SS') 
  AND my_code='33' 
  GROUP BY my_code;
  </code></pre>
  
  <p>Also, I want to be able to use this query dynamically by changing the part of the date to be whatever the current date is, but I want to be able to specify the hour. So I want to be comparing something like:</p>
  
  <pre><code>getdate() + 'T05.00.00'
  </code></pre>
  
  <p>I have no idea how to do this and the getdate() function doesn't seem to work in SQL Developer/I don't know how to use it correctly.</p>
  
  <p>So what I'm looking for is optimization suggestions and pointers on how to just dynamically change the day-month-year part of the date I want to constrain my results to. Thanks!</p>