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 -> Re: Century date mask & Y2K compliance

Re: Century date mask & Y2K compliance

From: Steve Cosner <stevec_at_zimmer.csufresno.edu>
Date: Sun, 19 Sep 1999 18:39:36 GMT
Message-ID: <I5aF3.16$dB1.2011@nntp.csufresno.edu>


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

Original text of this message

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