Re: Y2K Date Issues with Oracle 7.3.4
Date: Fri, 21 Jan 2000 05:47:05 GMT
Message-ID: <868rsl$c22$1_at_nnrp1.deja.com>
Obviously, to_date implicitly converts it's argument to a character, using to_char() and the nls_date_format of the current session. If you change the latter to 'DD.MM.RR', dates in the range from 1.1.1950 to 31.12.2049 are treated correctly:
select * from v$nls_parameters
where parameter = 'NLS_DATE_FORMAT'
yields:
NLS_DATE_FORMAT DD.MM.RR
The dbms-Output of the block
declare
wDate date ;
begin
wDate := to_date('31.12.1949','DD.MM.YYYY') ;
dbms_output.put_line('Before: ' || to_char(wDate,'DD.MM.YYYY')) ;
wDate := to_date(wDate) ;
dbms_output.put_line('After: ' || to_char(wDate,'DD.MM.YYYY')) ;
wDate := to_date('1.1.1950','DD.MM.YYYY') ;
dbms_output.put_line('Before: ' || to_char(wDate,'DD.MM.YYYY')) ;
wDate := to_date(wDate) ;
dbms_output.put_line('After: ' || to_char(wDate,'DD.MM.YYYY')) ;
wDate := to_date('31.12.2049','DD.MM.YYYY') ;
dbms_output.put_line('Before: ' || to_char(wDate,'DD.MM.YYYY')) ;
wDate := to_date(wDate) ;
dbms_output.put_line('After: ' || to_char(wDate,'DD.MM.YYYY')) ;
wDate := to_date('1.1.2050','DD.MM.YYYY') ;
dbms_output.put_line('Before: ' || to_char(wDate,'DD.MM.YYYY')) ;
wDate := to_date(wDate) ;
dbms_output.put_line('After: ' || to_char(wDate,'DD.MM.YYYY')) ;
end ;
is as follows:
Before: 31.12.1949
After: 31.12.2049
Before: 01.01.1950
After: 01.01.1950
Before: 31.12.2049
After: 31.12.2049
Before: 01.01.2050
After: 01.01.1950
In article <85qgh1$2nf2$1_at_ulysses.noc.ntua.gr>,
"Sofia" <sofia_at_eexi.gr> wrote:
> interesting fact:
>
> If you cast "to_date" a date variable (don't ask me why you would
> like to do that), then no matter how much care you took in placing
> the correct date in the variable, the result will be a date after
2000.
>
> For example
>
> a_date DATE;
>
> a_date := to_date('12/10/1998','DD/MM/YYYY');
> a_date := to_date(a_date);
>
> now a_date has a 12/10/2098 value!
>
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Fri Jan 21 2000 - 06:47:05 CET