Re: Y2K Date Issues with Oracle 7.3.4

From: Pierre Charpenay <pcharpenay_at_unilog.fr>
Date: Mon, 17 Jan 2000 13:23:02 +0100
Message-ID: <388309A6.CB2FA113_at_unilog.fr>


pberetta_at_my-deja.com a écrit :

> Sofia,
> And if you want to see something even more bizarre, look at what
> happened when I tried to prevent the century shift by specifying a
> format mask when TO_DATEing the date:
>
> SQL> DECLARE
> 2 a_date DATE;
> 3 BEGIN
> 4 a_date := to_date('12/10/1998','DD/MM/YYYY');
> 5 DBMS_OUTPUT.PUT_LINE(to_char(a_date,'DD/MM/YYYY'));
> 6 a_date := to_date(a_date);
> 7 DBMS_OUTPUT.PUT_LINE(to_char(a_date,'DD/MM/YYYY'));
> 8 a_date := to_date('12/10/1998','DD/MM/YYYY');
> 9 a_date := to_date(a_date,'DD/MM/YYYY');
> 10 DBMS_OUTPUT.PUT_LINE(to_char(a_date,'DD/MM/YYYY'));
> 11 END;
> 12 /
> 12/10/1998
> 12/10/2098
> 12/10/0098
>
> PL/SQL procedure successfully completed.
>
> Now where in heck did that 0098 come from? Proving once again you have
> to be VERY careful what you ask for when it comes to date I/O in Oracle.
> Hope this gives you a chuckle,
> Paul
>

I presume your default format is 'DD/MM/YY', so - lines 4 and 5 : OK
- lines 6 and 7 : automatic conversion of the date into char using the default format

                        gives '12/10/98' (using the current century for the
output)
- lines 9 and 10 : first automatic conversion like above, and conversion to a date using the
                          given format, so the '98' corresponds to 'YYYY' !

Funny !

Pierre Received on Mon Jan 17 2000 - 13:23:02 CET

Original text of this message