From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Robert wang <robert(dot)wang(at)eitec(dot)com(dot)tw> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #3237: function to_char() returns wrong value |
Date: | 2007-04-18 21:23:00 |
Message-ID: | 200704182123.l3ILN0C02607@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Robert wang wrote:
>
> The following bug has been logged online:
>
> Bug reference: 3237
> Logged by: Robert wang
> Email address: robert(dot)wang(at)eitec(dot)com(dot)tw
> PostgreSQL version: 8.2
> Operating system: Windows 2000 professional
> Description: function to_char() returns wrong value
> Details:
>
> I run this following SQL command in pgAdminIII:
>
> Select to_char(12345,'00000')
>
> but it always returns ' 12345' (hex code: 20 31 32 33 34 35).It always adds
> one space char in the left side.
>
> I have to use another function substring() as followings to get my expected
> value.
>
> Select substring(to_char(12345,'00000'),from ' ' for 5)
>
> it exactly returns '12345' which I expect.
My guess is that the extra space is for the minus sign. Use "FM" to
supress padding:
test=> SELECT length(to_char(12345,'FM00000'));
length
--------
5
(1 row)
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
From | Date | Subject | |
---|---|---|---|
Next Message | Kevin Macdonald | 2007-04-18 22:10:03 | BUG #3240: Unexpected evaluation sequence |
Previous Message | Tom Lane | 2007-04-18 17:24:27 | Re: BUG #3236: Partitioning has problem with timestamp and timestamptz data type |