Thread: function to_char
Hi, using postgres 12.5.
The to_char function has a problem with format length.
Example, select length (to_char (1, '990'))
returns 4 because?
if the format has length 3?
![]() | El software de antivirus Avast ha analizado este correo electrónico en busca de virus. |
Hi,
Le sam. 17 avr. 2021 à 15:05, Fontana Daniel C. (Desartec S.R.L.) <desartecsrl@gmail.com> a écrit :
Hi, using postgres 12.5.
The to_char function has a problem with format length.
Example, select length (to_char (1, '990'))
returns 4 because?
if the format has length 3?
Actually, the format length isn't 3. It is 4 because you need one character to put the sign when needed.
postgres=# select '<'||to_char (+999, '990')||'>';
?column?
----------
< 999>
(1 row)
postgres=# select '<'||to_char (-999, '990')||'>';
?column?
----------
<-999>
(1 row)
?column?
----------
< 999>
(1 row)
postgres=# select '<'||to_char (-999, '990')||'>';
?column?
----------
<-999>
(1 row)
--
Guillaume.