Thread

  1. CC Date format code defaults to current centry

    Joe Brown <joebrown@rclooke.com> — 2005-03-08T17:40:02Z

    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.
    
    
  2. Re: CC Date format code defaults to current centry

    Bruce Momjian <pgman@candle.pha.pa.us> — 2005-03-14T02:24:33Z

    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
    
    
  3. Re: CC Date format code defaults to current centry

    Andre Maasikas <andre@abs.ee> — 2005-03-14T11:11:58Z

    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
    
    
    
  4. Re: [BUGS] CC Date format code defaults to current centry

    Karel Zak <zakkr@zf.jcu.cz> — 2005-03-17T09:50:51Z

    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@zf.jcu.cz>
    
  5. Re: [BUGS] CC Date format code defaults to current centry

    Tom Lane <tgl@sss.pgh.pa.us> — 2005-03-25T16:09:30Z

    Karel Zak <zakkr@zf.jcu.cz> writes:
    >  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:
    > ...
    > The patch (with docs changes) is in the attachment.
    
    Applied to HEAD and 8.0.
    
    			regards, tom lane