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

Home -> Community -> Usenet -> c.d.o.server -> decode/to_date in an insert

decode/to_date in an insert

From: <euroman_at_my-deja.com>
Date: 2000/07/26
Message-ID: <8lnfaa$37a$1@nnrp1.deja.com>#1/1

In an INSERT statement, using to_date (decode ()) works fine but decode (to_date ()) gets the current century, as follows:

create table z (x date);
insert into z values (to_date ('19990304', 'yyyymmdd')); select to_char (x, 'mm/dd/yyyy') from z ;
/*

returns

03/04/1999

as expected
*/
insert into z values (decode ('a', 'b', null, to_date ('19450506','yyyymmdd')));
select to_char (x, 'mm/dd/yyyy') from z ;
/*

returns
TO_CHAR(X,



03/04/1999
05/06/2045 -- NOT EXPECTED
However,
*/
insert into z values (to_date (decode ('a', 'b', null, '19340302'), 'yyyymmdd'));
select to_char (x, 'mm/dd/yyyy') from z ;
/*

returns
TO_CHAR(X,
03/04/1999
05/06/2045
03/02/1934

*/

Any explanation is appreciated. Thanks.

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Wed Jul 26 2000 - 00:00:00 CDT

Original text of this message

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