Thread: to_char(0,'9999.99') -> ".00"
Dear All, I was a bit surprised to find that to_char(0,'9999.99') returns .00 rather than 0.00. Is this a bug or a feature? How do I get what I want? (This is with 7.4.2. Appologies if it is a known problem. The search form in the list archives seems to split words on _, so looking for to_char finds lots of pages that just say 'char'.) Regards, Phil Endecott.
to_char(0,'9990.00') ? On Mon, 2005-01-10 at 22:48 +0000, Phil Endecott wrote: > Dear All, > > I was a bit surprised to find that > > to_char(0,'9999.99') > > returns .00 rather than 0.00. > > Is this a bug or a feature? How do I get what I want? > > (This is with 7.4.2. Appologies if it is a known problem. The search > form in the list archives seems to split words on _, so looking for > to_char finds lots of pages that just say 'char'.) > > Regards, > > Phil Endecott. > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faqs/FAQ.html -- Dave Smith <dave.smith@candata.com>
I asked: >> to_char(0,'9999.99') >> >>returns .00 rather than 0.00. Dave Smith replied: > to_char(0,'9990.00') > ? Thanks Dave, that's embarrassingly obvious... I note that the examples in the documentation don't have a 0 before the decimal point, e.g. this one to_char(148.5, 'FM999.990') '148.500' I imagine that in most cases people do want '0.000' rather than '.000', so perhaps these examples should be changed to, in this case, 990.000. Regards, --Phil.