pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Fuhr <mike@fuhr.org>
To: Andy Shellam <andy@andycc.net>
Cc: pgsql-admin@postgresql.org
Subject: Re: Number formatting
Date: Sat, 10 Jun 2006 12:28:23 -0600
Message-ID: <20060610182823.GA91044@winnie.fuhr.org> (raw)
In-Reply-To: <448B0C26.8070007@andycc.net>
References: <448B0C26.8070007@andycc.net>

On Sat, Jun 10, 2006 at 07:15:02PM +0100, Andy Shellam wrote:
> So, what I'm trying to do is use a primary key to generate invoice
> numbers such as "INV0000001", "INV0000002" etc.  Obviously a sequence
> generates the increments, but when I try formatting it, it adds a space
> at the beginning of the number.

The FM modifier suppresses padding spaces.

http://www.postgresql.org/docs/8.1/interactive/functions-formatting.html#FUNCTIONS-FORMATTING-DATETI...

test=> SELECT 'INV' || to_char(123, 'FM0000000');
  ?column?  
------------
 INV0000123
(1 row)

-- 
Michael Fuhr



view thread (3+ messages)  latest in thread

Message-ID: <20060610182823.GA91044@winnie.fuhr.org>
Permalink:  ../20060610182823.GA91044@winnie.fuhr.org/
Also on:    postgresql.org/message-id/20060610182823.GA91044@winnie.fuhr.org

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: mike@fuhr.org, andy@andycc.net
  Subject: Re: Number formatting
  In-Reply-To: <20060610182823.GA91044@winnie.fuhr.org>
  References: <448B0C26.8070007@andycc.net> <20060610182823.GA91044@winnie.fuhr.org>

* 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