Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Inconsistency while retrieving rows in sequel query.(To_Char)
"Bmfcv" <bmfcv_at_cs.com> wrote in message
news:20010714221411.23516.00004348_at_ng-mg1.news.cs.com...
>
> When I use YY as fromat model in TO_CHAR function, I get Sunday as the
Day of
> my birthday.
> And when I use YYYY as fromat Model I get Monday.
> Why is this inconsistency in Oracle? or Am I doing something wrong???
> I use Oracle 8.1.6.
>
>
>
> SQL> SELECT TO_CHAR(TO_DATE('01-20-75','MM-DD-YY'),'Day') "My Birthday"
FROM
> dual;
>
> My Birthd
> ---------
> Sunday
>
>
> SQL> SELECT TO_CHAR(TO_DATE('01-20-1975','MM-DD-YYYY'),'Day') "My
Birthday"
> FROM dual;
>
> My Birthd
> ---------
> Monday
Oracle will derive all not specified date elements from the sysdate. In the first example you don't specify a century, so it takes the century from the sysdate as 20, which is the 21st century. Try changing the format YY in RR and you should get correct results
Hth,
Sybrand Bakker, Senior Oracle DBA Received on Sat Jul 14 2001 - 23:46:00 CDT
![]() |
![]() |