pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Bruce Momjian <pgman@candle.pha.pa.us>
To: Gary Stainburn <gary.stainburn@ringways.co.uk>
Cc: pgsql-sql <pgsql-sql@postgresql.org>
Subject: Re: where'd the spaces come from
Date: Fri, 3 Aug 2001 10:39:42 +0100
Message-ID: <01b001c11c00$3ae2bbc0$1001a8c0@archonet.com> (raw)
References: <200108021631.f72GV8T03473@candle.pha.pa.us>

From: "Bruce Momjian" <pgman@candle.pha.pa.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





view thread (7+ messages)

Message-ID: <01b001c11c00$3ae2bbc0$1001a8c0@archonet.com>
Permalink:  ../01b001c11c00$3ae2bbc0$1001a8c0@archonet.com/
Also on:    postgresql.org/message-id/01b001c11c00$3ae2bbc0$1001a8c0@archonet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dev@archonet.com, pgman@candle.pha.pa.us, gary.stainburn@ringways.co.uk
  Subject: Re: where'd the spaces come from
  In-Reply-To: <01b001c11c00$3ae2bbc0$1001a8c0@archonet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox