Skip site navigation (1) Skip section navigation (2)

Re: How to trim values?

From: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
To: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
Cc: jkakar(at)expressus(dot)com, pgsql-sql(at)postgresql(dot)org
Subject: Re: How to trim values?
Date: 2000-12-30 10:34:19
Message-ID: Pine.LNX.3.96.1001230113338.19982D-100000@ara.zf.jcu.cz (view raw or flat)
Thread:
Lists: pgsql-sql
On Thu, 28 Dec 2000, Oliver Elphick wrote:

> jkakar(at)expressus(dot)com wrote:
>   >Hi,
>   >
>   >I'm trying to figure out how to take a value like 3.68009074974387
>   >(that is calculated from values in my database) and have PostgreSQL
>   >hand me 3.68.  Any suggestions would be appreciated.
> 
> cast it to numeric(x,2)
> 
> (where x is the total number of digits, and 2 is two decimal places).
> 
> template1=# select  3.68009074974387::numeric(3,2);
>  ?column? 
> ----------
>      3.68
> (1 row)
> 
> or use round(value,2)
> 
> 
> template1=# select round(3.68009074974387, 2);
>  round 
> -------
>   3.68
> (1 row)

or

test=# select to_char(3.68009074974387, '99.99');
 to_char
---------
   3.68
(1 row)

			Karel


In response to

pgsql-sql by date

Next:From: Kaare RasmussenDate: 2000-12-30 10:45:38
Subject: Re: Date/Time problem -(((
Previous:From: BorisDate: 2000-12-30 09:36:25
Subject: Date/Time problem -(((

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group