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

Re: [BUGS] CC Date format code defaults to current centry

From: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: List pgsql-patches <pgsql-patches(at)postgreSQL(dot)org>
Subject: Re: [BUGS] CC Date format code defaults to current centry
Date: 2005-03-17 09:50:51
Message-ID: 1111053051.4169.242.camel@petra (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-patches
On Sun, 2005-03-13 at 21:24 -0500, Bruce Momjian wrote:
> Joe Brown wrote:
> > joe=> select to_date('19450323','CCYYMMDD');
> >   to_date  
> > ------------
> >  2045-03-23
> > (1 row)
> > 
> > joe=> select to_date('19450323','YYYYMMDD');
> >   to_date  
> > ------------
> >  1945-03-23
> > (1 row)
> > 
> > I thought the former would be "more" correct.  But it seems I am mistaken.
> 
> Uh, 1945 _is_ in the 20th century, but I can see how it is confusing.

It ignored CC value if there was YY (YYYY, ..). And YY=45 is 2045:

 /*
  * 2-digit year
  */
 if (tmfc->year < 70)
   tmfc->year += 2000;
 else
   tmfc->year += 1900;


 I think it's very special case when you define YY and CC and code
should detects it and counts year as (CC-1)*100+YY. The right answers:

CC+YY

test=# select to_date('20450112', 'CCYYDDMM');
  to_date
------------
 1945-12-01

CC+Y

test=# select to_date('2090112', 'CCYDDMM');
  to_date
------------
 1909-12-01


For YYY/YYYY it ignore CC option.

The patch (with docs changes) is in the attachment.

	Karel


-- 
Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>

Attachment: formatting-17032005.patch.gz
Description: application/x-gzip (1.3 KB)

In response to

Responses

pgsql-bugs by date

Next:From: Mehul Doshi-A20614Date: 2005-03-17 17:41:25
Subject: Weak Password!
Previous:From: Spencer RidderingDate: 2005-03-17 08:48:54
Subject: BUG #1550: LOCK TABLE in plpgsql function doesn't work.

pgsql-patches by date

Next:From: a_ogawaDate: 2005-03-17 14:20:18
Subject: Re: WIP: avoiding tuple construction/deconstruction overhead
Previous:From: Simon RiggsDate: 2005-03-17 09:13:50
Subject: Re: read-only database

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