Re: where'd the spaces come from

From: "Richard Huxton" <dev(at)archonet(dot)com>
To: "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>, "Gary Stainburn" <gary(dot)stainburn(at)ringways(dot)co(dot)uk>
Cc: "pgsql-sql" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: where'd the spaces come from
Date: 2001-08-03 09:39:42
Message-ID: 01b001c11c00$3ae2bbc0$1001a8c0@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

From: "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>

> > Hi Bruce,
> >
> > a fix for what?
> > If you're meaning the leading space, then the fix is in the followup
post
> > that I made to my original quiestion. i.e.
> >
> > psql -c "select to_char(12,'xFM000');"
> > to_char
> > ---------
> > x012
> > (1 row)
> >
> > The 'FM' removes the space.
>
> So the FM is the correct way to do this, right? There is no bug?

Well - it's certainly *unexpected* behaviour isn't it?

It is documented though (Karel Zak's given plenty of examples too):

"FM suppresses leading zeroes or trailing blanks that would otherwise be
added to make the output of a pattern be fixed-width"

Some of the examples show the difference too:

to_char(12,'9990999.9') => ' 0012.0'
to_char(12,'FM9990999.9') => '0012'

I think the issue is you look at to_char() and make assumptions if you're
not familiar with it. I *seem* to remember someone saying Oracle worked this
way.

- Richard Huxton

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Christopher Sawtell 2001-08-03 09:41:40 Re: Activation of plsql
Previous Message David Lizano 2001-08-03 09:29:45 Activation of plsql