title: Oracle date compare broken because of DST
body: <p>We've been debugging an issue with a SQL query executed from an app server running Java via Hibernate. The error:</p>
  
  <pre><code>[3/10/14 10:52:07:143 EDT] 0000a984 JDBCException W org.hibernate.util.JDBCExceptionReporter logExceptions SQL Error: 1878, SQLState: 22008
  [3/10/14 10:52:07:144 EDT] 0000a984 JDBCException E org.hibernate.util.JDBCExceptionReporter logExceptions ORA-01878: specified field not found in datetime or interval
  </code></pre>
  
  <p>We've been able to narrow this down to the simple SQL below.</p>
  
  <pre><code>select * 
  from MY_TABLE T
  where T.MY_TIMESTAMP &gt;= (CURRENT_TIMESTAMP - interval '1' hour );
  </code></pre>
  
  <p>When we run this in the same database, we get the error:</p>
  
  <pre><code>ORA-01878: specified field not found in datetime or interval
  01878. 00000 -  "specified field not found in datetime or interval"
  *Cause:    The specified field was not found in the datetime or interval.
  *Action:   Make sure that the specified field is in the datetime or interval.
  </code></pre>
  
  <p>The <code>MY_TIMESTAMP</code> column is defined as <code>TIMESTAMP(6)</code>.</p>
  
  <p>FWIW, if we change the comparison in the SQL above from <code>>=</code> to <code>&lt;=</code>, the query works.</p>
  
  <p>We assume this has something to do with the time change (we're in America/New_York) but we're having problems trying to figure out where to go from here with our debugging.</p>
  
  <p>Also, we've seen this problem with a similar query that's running through MyBatis and the error looks like:</p>
  
  <pre><code>### Error querying database.  Cause: java.sql.SQLException: ORA-01878: specified field not found in datetime or interval
  
  ### The error may involve defaultParameterMap
  ### The error occurred while setting parameters
  ### Cause: java.sql.SQLException: ORA-01878: specified field not found in datetime or interval
  </code></pre>
  
  <p>UPDATE: A teammate on Windows changed her Windows Date and Time settings by un-checking "Automatically adjust clock for Daylight Saving Time" and then opened a new SQLDeveloper instance. The second instance is able to run the query without any issue but the first (with the old DST setting) still fails.</p>