| 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 | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Kaare Rasmussen | 2000-12-30 10:45:38 | Re: Date/Time problem -((( | 
| Previous Message | Boris | 2000-12-30 09:36:25 | Date/Time problem -((( |