Re: FM suffix in to_char Y/YY/YYY still screwy

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: FM suffix in to_char Y/YY/YYY still screwy
Date: 2010-04-14 21:52:57
Message-ID: 201004142152.o3ELqvs08958@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> I thought we'd fixed this ...
>
> regression=# select to_char('2009-01-01'::date, 'YY');
> to_char
> ---------
> 09
> (1 row)
>
> regression=# select to_char('2009-01-01'::date, 'FMYY');
> to_char
> ---------
> 09
> (1 row)
>
> Not a lot of zero suppression happening there :-(.
>
> I believe the correct fix is to reduce the year mod 100 (or 10 or 1000)
> before feeding it to snprintf, rather than playing games with printing
> only part of the result string as the original and current code try to
> do.

Agreed. Thanks for the fix.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jaime Casanova 2010-04-14 21:57:08 Re: Thoughts on pg_hba.conf rejection
Previous Message Robert Haas 2010-04-14 21:51:38 Re: Thoughts on pg_hba.conf rejection