Leading zero
Posted in 2006
Topics: General Discussion
Does anyone have an alogorithm to convert a numeric column to a character column with leading zeroes? Eg. Row 1 col = 2 Row 2 col = 232 Row 3 col = 24332 Would like Row 1 col = 000002 Row 2 col = 000232 Row 3 col = 024332 Thanks, Tony
Demeis, Tony wrote: > Does anyone have an alogorithm to convert a numeric column to a character > column with leading zeroes? > > Eg. > Row 1 col = 2 > Row 2 col = 232 > Row 3 col = 24332 > > Would like > > Row 1 col = 000002 > Row 2 col = 000232 > Row 3 col = 024332 > > Thanks, > Tony use sqsl, see sig -- Ciao, Marco ______________________________________________________________________________ Marco Greco /UK /IBM Standard disclaimers apply! Structured Query Scripting Language http://www.4glworks.com/sqsl.htm 4glworks http://www.4glworks.com Informix on Linux http://www.4glworks.com/ifmxlinux.htm
I assume this is for a select statement how about select lpad(fieldname, 6, '0') from whatevertable >From: "Demeis, Tony" <Tony.Demeis@moh.gov.on.ca> >Reply-To: ids@iiug.org >To: ids@iiug.org >Subject: Leading zero [6407] >Date: Thu, 16 Feb 2006 10:23:40 -0500 (EST) > >Does anyone have an alogorithm to convert a numeric column to a character >column with leading zeroes? > >Eg. >Row 1 col = 2 >Row 2 col = 232 >Row 3 col = 24332 > >Would like > >Row 1 col = 000002 >Row 2 col = 000232 >Row 3 col = 024332 > >Thanks, >Tony > > >******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > _________________________________________________________________ Need pet-care advice? Find it with MSN Search! http://search.msn.co.za
Thanks. Is there a right pad function as well? -----Original Message----- From: ids-bounces@iiug.org [mailto:ids-bounces@iiug.org] On Behalf Of Mark Tyrer Sent: Thursday, February 16, 2006 10:32 AM To: ids@iiug.org Subject: RE: Leading zero [6409] I assume this is for a select statement how about select lpad(fieldname, 6, '0') from whatevertable >From: "Demeis, Tony" <Tony.Demeis@moh.gov.on.ca> >Reply-To: ids@iiug.org >To: ids@iiug.org >Subject: Leading zero [6407] >Date: Thu, 16 Feb 2006 10:23:40 -0500 (EST) > >Does anyone have an alogorithm to convert a numeric column to a >character column with leading zeroes? > >Eg. >Row 1 col = 2 >Row 2 col = 232 >Row 3 col = 24332 > >Would like > >Row 1 col = 000002 >Row 2 col = 000232 >Row 3 col = 024332 > >Thanks, >Tony > > >*********************************************************************** >******** Forum Note: Use "Reply" to post a response in the discussion >forum. > _________________________________________________________________ Need pet-care advice? Find it with MSN Search! http://search.msn.co.za **************************************************************************** *** Forum Note: Use "Reply" to post a response in the discussion forum.
Hi Tony, I lifted this straight from the SQL syntax manual SELECT RPAD('Where are you', 18, '?!') FROM mytable The following shows the output of this SELECT statement. Where are you?!?!? >From: "Demeis, Tony" <Tony.Demeis@moh.gov.on.ca> >Reply-To: ids@iiug.org >To: ids@iiug.org >Subject: RE: Leading zero [6417] >Date: Thu, 16 Feb 2006 11:58:04 -0500 (EST) > >Thanks. >Is there a right pad function as well? > >-----Original Message----- >From: ids-bounces@iiug.org [mailto:ids-bounces@iiug.org] On Behalf Of Mark >Tyrer >Sent: Thursday, February 16, 2006 10:32 AM >To: ids@iiug.org >Subject: RE: Leading zero [6409] > >I assume this is for a select statement > >how about > >select lpad(fieldname, 6, '0') from whatevertable > > >From: "Demeis, Tony" <Tony.Demeis@moh.gov.on.ca> > >Reply-To: ids@iiug.org > >To: ids@iiug.org > >Subject: Leading zero [6407] > >Date: Thu, 16 Feb 2006 10:23:40 -0500 (EST) > > > >Does anyone have an alogorithm to convert a numeric column to a > >character column with leading zeroes? > > > >Eg. > >Row 1 col = 2 > >Row 2 col = 232 > >Row 3 col = 24332 > > > >Would like > > > >Row 1 col = 000002 > >Row 2 col = 000232 > >Row 3 col = 024332 > > > >Thanks, > >Tony > > > > > > >*********************************************************************** > >******** Forum Note: Use "Reply" to post a response in the discussion > >forum. > > > >_________________________________________________________________ >Need pet-care advice? Find it with MSN Search! http://search.msn.co.za > >**************************************************************************** >*** >Forum Note: Use "Reply" to post a response in the discussion forum. > > >******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > _________________________________________________________________ Find just what you're after on your PC with Windows Desktop Search - FREE! http://desktop.msn.co.za/