Hi,

Le sam. 17 avr. 2021 à 15:05, Fontana Daniel C. (Desartec S.R.L.) <
desartec...@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)


-- 
Guillaume.
  • function to_char Fontana Daniel C. (Desartec S.R.L.)
    • Re: function to_char Guillaume Lelarge

Reply via email to