Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Y2K problem using JDBC to extract dates from Oracle

Re: Y2K problem using JDBC to extract dates from Oracle

From: Dave Smith <smith_at_ali.com.au>
Date: Thu, 09 Mar 2000 21:25:34 GMT
Message-ID: <8a94s6$5cj$1@nnrp1.deja.com>


In article <38C7DD0B.508C4DB8_at_bellsouth.net>,   Dare Obasanjo <kpako_at_bellsouth.net> wrote:
> I have a database table that contains the following date '12-DEC-95'.
>
> When I extract the table using a ResultSet object and call getString
() I
> get the
> following
>
> 2095-12-12 00:00:00.0
>
> is there any way to set pivot years or are there methods that make
this
> relatively
> simple. The reason I ask is that the problem is easily fixable with a
> little parsing
> but I'd hate to reinvent the wheel on this one.
> Thanks in advance.
>
> PS: I am using jdk1.1.8 with oracle 8.1.5 on Windows 98SE.
>
>

Are you sure that the date in the database is in 1995?

Try

select to_char(date_field, 'dd-mon-yyyy HH24:MI:SS') from date_table;

and I suspect that you will find that the date in the database is 2095. This will suggest that you are inserting it incorrectly, rather than JDBC retrieving it incorrectly.

Always insert dates using 4 digit years, or if you are going to use 2 digits use the RR mask

e.g.

insert tablename(fieldname) values to_date('1-jan-05','dd-mon-RR');

If you do not specify a century and do not use the RR date format you get 2000.

Look up NLS in the docs and set the environment variable for the date format to use RR by default.

--
Dave Smith
Aristocrat Leisure Industries Pty Ltd
Sydney
Australia

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Thu Mar 09 2000 - 15:25:34 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US