Re: Trunc in Postgres

From: elein <elein(at)varlena(dot)com>
To: Jeff Eckermann <jeff_eckermann(at)yahoo(dot)com>
Cc: Amin Schoeib <aschoeib(at)4tek(dot)de>, pgsql-general(at)postgresql(dot)org
Subject: Re: Trunc in Postgres
Date: 2003-09-06 19:55:04
Message-ID: 20030906125504.E18990@cookie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Try:
select '0000000000000000000000041'::integer;

Just turn it into a number if you want to truncate the
leading zeros. But if you want text output,
trim() trim is it.

Trim() trims from text fields.
select trim( '0' from '00000000000000000000000041');

Also see the replace() function.

--elein

On Wed, Sep 03, 2003 at 07:44:34AM -0700, Jeff Eckermann wrote:
> Look at the "trim" function.
> While you are about it, looking over the other
> available functions would be worth your while too
> (look under "Functions and Operators" in the docs).
>
> --- Amin Schoeib <aschoeib(at)4tek(dot)de> wrote:
> >
> > Hi,
> > Is there an equivalent for the trunc function of
> > Oracle in Postgres???
> > I need to trunc(the zeros) a number which is stored
> > as a char with a lot of zeros
> > Like that : 0000000000000000000000000000004
> >
> > In oracle you can make that by
> > trunc(YOUR_COLUMNNAME,0)
> >
> > Thanxx
> >
> > Schoeib
> >
> > 4Tek Gesellschaft f?r angewandte
> > Informationstechnologien mbH
> > Schoeib Amin
> > Tel. +49 (0) 69 697688-132
> > Fax. +49 (0) 69 697688-111
> > http://www.4tek.de
> >
> >
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Franco Bruno Borghesi 2003-09-07 00:07:38 SRF question
Previous Message Stephan Szabo 2003-09-06 19:44:14 Re: Optimizer picks an ineffient plan