X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (developer.postgresql.org [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id A9ECFB4394B for ; Tue, 8 Jul 2003 20:26:33 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 34711-09 for ; Tue, 8 Jul 2003 17:26:22 -0300 (ADT) Received: from dbdevel.sunwave.net (h64-141-16-15.sunwave.net [64.141.16.15]) by svr1.postgresql.org (Postfix) with ESMTP id 47B3AB430C2 for ; Tue, 8 Jul 2003 17:26:22 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by dbdevel.sunwave.net (Postfix) with ESMTP id B0EDF178008; Tue, 8 Jul 2003 16:26:23 -0400 (EDT) From: Michael A Nachbaur To: Yasir Malik , pgsql-sql@postgresql.org Subject: Re: Datatype conversion help Date: Tue, 8 Jul 2003 13:26:23 -0700 User-Agent: KMail/1.5 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200307081326.23538.mike@nachbaur.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/87 X-Sequence-Number: 14201 You want to use: nachbaur=# select to_char(5, '00'); to_char --------- 05 (1 row) By using "0", you indicate you want leading zeros. See http://www.postgresql.org/docs/view.php?version=7.3&idoc=1&file=functions-formatting.html for more information. On Tuesday 08 July 2003 01:07 pm, Yasir Malik wrote: > Suppose I have an integer between 0 and 99 and I want to covert it to > string, and pad leading zeros if neccessary. For example, > 1 => 01 > 10 => 10 > > I've tried to_char(in_val, '99'), and that returns a string that is two > charecters, but there isn't a leading zero incase I have the number 2 as > input. Any ideas? Thanks. > Yasir > > ---------------------------(end of broadcast)--------------------------- > TIP 7: don't forget to increase your free space map settings -- /* Michael A. Nachbaur * http://nachbaur.com/pgpkey.asc */ "Oh no, not again."