function to_char

Started by Fontana Daniel C (Desartec S.R.L.)almost 5 years ago2 messagesbugs
Jump to latest

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.
https://www.avast.com/antivirus

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Fontana Daniel C (Desartec S.R.L.) (#1)
Re: function to_char

"Fontana Daniel C. \(Desartec S.R.L.\)" <desartecsrl@gmail.com> writes:

Example, select length (to_char (1, '990'))
returns 4 because?

Per the fine manual:

* If no explicit provision is made for a sign in to_char()'s pattern,
one column will be reserved for the sign, and it will be anchored to
(appear just left of) the number. If S appears just left of some
9's, it will likewise be anchored to the number.

If you don't want to leave space for a sign, it looks like FM is
the only way to do that.

regards, tom lane