Re: FM suffix in to_char Y/YY/YYY still screwy - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: FM suffix in to_char Y/YY/YYY still screwy
Date
Msg-id 201004142152.o3ELqvs08958@momjian.us
Whole thread Raw
In response to FM suffix in to_char Y/YY/YYY still screwy  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Thoughts on pg_hba.conf rejection
Next
From: Jaime Casanova
Date:
Subject: Re: Thoughts on pg_hba.conf rejection