| 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 |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs pgsql-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 | Content-Type | Size |
|---|---|---|
| formatting-17032005.patch.gz | application/x-gzip | 1.3 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Mehul Doshi-A20614 | 2005-03-17 17:41:25 | Weak Password! |
| Previous Message | Spencer Riddering | 2005-03-17 08:48:54 | BUG #1550: LOCK TABLE in plpgsql function doesn't work. |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | a_ogawa | 2005-03-17 14:20:18 | Re: WIP: avoiding tuple construction/deconstruction overhead |
| Previous Message | Simon Riggs | 2005-03-17 09:13:50 | Re: read-only database |