2 Replies Latest reply: Jul 20, 2012 6:29 PM by 950834 RSS

    Error selecting dates around DST

    950834

      I am having a problem selecting dates from a database at the office. I seem to be unable to select anything on the EDT switchover. I have tried various JDBC versions and it seems to be always wrong. below is my output followed by the code.

      I would expect to see this:
      2012-03-11 02:24:00.0
      2012-03-11 03:24:00.0

      What I get
      -----------------------------
      ojdbc14-10.1.0.2.0.jar
      2012-03-11 01:24:00.0
      2012-03-11 03:24:00.0

      ojdbc6_g-11.2.0.2.0.jar
      2012-03-11 03:24:00.0
      2012-03-11 03:24:00.0

      ojdbc6_g-11.2.0.3.jar
      2012-03-11 03:24:00.0
      2012-03-11 03:24:00.0

      import java.sql.*; public class JDBCTest {   public  static void main(String[] args) throws SQLException {     DriverManager.registerDriver(new oracle.jdbc.OracleDriver());     ResultSet bat = DriverManager.       getConnection("--JDBCURL--", "username", "password").       prepareCall("select to_date('3/11/2012 02:24:00','mm/dd/yyyy HH:MI:SS') theDate from dual").       executeQuery();     bat.next();     System.out.println(bat.getTimestamp("theDate"));   ResultSet man = DriverManager.       getConnection("--JDBCURL-", "username", "password").       prepareCall("select to_date('3/11/2012 03:24:00','mm/dd/yyyy HH:MI:SS') theDate from dual").       executeQuery();     man.next();     System.out.println(man.getTimestamp("theDate"));   } }

      Any ideas on what could be going wrong? What kind of stuff should I be looking at in the DB environment? Is this a potential bug I should file somewhere? Thanks

        • 1. Re: Error selecting dates around DST
          rp0428
          >
          I would expect to see this:
          2012-03-11 02:24:00.0
          2012-03-11 03:24:00.0
          >
          Your expectations are wrong. There is no 2am thru 2:59:59 am during DST. At 2am the clock moves to 3am so 02:24:00 does not exist.

          I get the same results for all of those jar files (including 1.4) except I am not using the _g versions.
          >
          2012-03-11 03:24:00.0
          2012-03-11 03:24:00.0
          2012-03-11 01:59:59.0
          2012-03-11 03:00:00.0 -- value used was for 02:00:00
          >
          See Support for Daylight Saving Times in the SQL Language Reference
          http://docs.oracle.com/cd/B28359_01/server.111/b28286/sql_elements001.htm
          • 2. Re: Error selecting dates around DST
            950834
            Heh, you know... I honestly feel a really silly but you are right. Thanks!

            It troubles me that you are getting the 3:24 with the 1.4 Jar and I am not though...

            Thanks again.