Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Century date mask & Y2K compliance
In article <7rtgna$83e$1_at_nnrp1.deja.com>,
Neil Emery <neil.emery_at_virgin.net> wrote:
>All,
> We have a date checking algorithm which uses the century format which
> is giving inconsistent results depending on the system date
>
> This Unix box has system date set to today's date
>
> SQL> select to_char(to_date('01-jan-2000', 'dd-mon-yyyy'), 'cc') from
>dual;
>
> TO
> --
> 21
It does not matter what the system date is. The century on 01-Jan-2000 is 21. We are in the last year of the 20th century, next year is the 21st!
Try this in SQL Plus:
column today format a12
column century format a10
column "YEAR CEN." format a10
select to_char(sysdate,'dd-Mon-yyyy') today, to_char(sysdate,'cc') century, to_char(to_date('01012000','MMDDYYYY'),'yyyy cc') "YEAR CEN."from dual;
Here's what I get:
TODAY CENTURY YEAR CEN.
------------ ---------- ----------
19-Sep-1999 20 2000 21
Steve Cosner Received on Sun Sep 19 1999 - 13:39:36 CDT
![]() |
![]() |