CC Date format code defaults to current centry

Поиск
Список
Период
Сортировка
Искать

CC Date format code defaults to current centry

От:
Joe Brown <joebrown@rclooke.com>
Дата:
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.

Re: CC Date format code defaults to current centry

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
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.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: CC Date format code defaults to current centry

От:
Andre Maasikas <andre@abs.ee>
Дата:
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.
> 
Yes, but the other way around: to_date('19450323','CCYYMMDD')
shoold be a year in the 19th century?

ps another db seems to disallow CC on input - maybe because one can
get into weird situations like to_date('2005 18','YYYY CC') or something 
similar.

Andre
FAQ