Skip site navigation (1) Skip section navigation (2)

Re: BUG #2885: to_char function

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Akio Iwaasa <iwaasa(at)mxs(dot)nes(dot)nec(dot)co(dot)jp>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #2885: to_char function
Date: 2007-01-12 20:06:25
Message-ID: 200701122006.l0CK6PC01565@momjian.us (view raw or flat)
Thread:
Lists: pgsql-bugs
I updated our documentation for CC:

        <entry>century component of year (minimum 2 digits)</entry>


---------------------------------------------------------------------------

Tom Lane wrote:
> "Akio Iwaasa" <iwaasa(at)mxs(dot)nes(dot)nec(dot)co(dot)jp> writes:
> > When I've used "to_char" function to convert "Date" to 
> > "century" format text, '2000-01-01' was converted in 
> > the 21st century.
> 
> >  postgres=# select to_char('2000-01-01'::date, 'CC') ;
> >   to_char
> >  ---------
> >   21
> >  (1 row)
> 
> I'm not entirely sure that this is wrong, because of the behavior of
> the Y and YY fields.
> 
> regression=# select to_char('2007-01-01'::date, 'CC YY') ;
>  to_char
> ---------
>  21 07
> (1 row)
> 
> regression=# select to_date('21 07', 'CC YY');
>   to_date
> ------------
>  2007-01-01
> (1 row)
> 
> regression=# select to_char('2000-01-01'::date, 'CC YY') ;
>  to_char
> ---------
>  21 00
> (1 row)
> 
> regression=# select to_date('21 00', 'CC YY');
>   to_date
> ------------
>  2000-01-01
> (1 row)
> 
> If we make CC treat 2000 as being in the 20th century, what should YY
> do?
> 
> Perhaps more to the point, how do these things act in Oracle?
> to_char is basically an Oracle-compatibility function so we should
> adopt their bugs :-(
> 
> 			regards, tom lane
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 7: You can help support the PostgreSQL project by donating at
> 
>                 http://www.postgresql.org/about/donate

-- 
  Bruce Momjian   bruce(at)momjian(dot)us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

In response to

Responses

pgsql-bugs by date

Next:From: Tom LaneDate: 2007-01-12 20:12:51
Subject: Re: BUG #2885: to_char function
Previous:From: Jorge GodoyDate: 2007-01-12 15:53:04
Subject: Re: BUG #2885: to_char function

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group