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','MMDD');
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 (, ..). 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/ it ignore CC option.
The patch (with docs changes) is in the attachment.
Karel
--
Karel Zak [EMAIL PROTECTED]
formatting-17032005.patch.gz
Description: GNU Zip compressed data
---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send unregister YourEmailAddressHere to [EMAIL PROTECTED])