pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How to trim values?
3+ messages / 3 participants
[nested] [flat]

* How to trim values?
@ 2000-12-28 22:00 jkakar@expressus.com
  2000-12-28 22:45 ` Re: How to trim values? Oliver Elphick <olly@lfix.co.uk>
  0 siblings, 1 reply; 3+ messages in thread

From: jkakar@expressus.com @ 2000-12-28 22:00 UTC (permalink / raw)
  To: pgsql-sql

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.

Thanks,
Jamu.

-- 
Jamu Kakar (Developer)			Expressus Design Studio, Inc.
jkakar@expressus.com			708-1641 Lonsdale Avenue
V: (604) 903-6999			North Vancouver, BC, V7M 2J5



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: How to trim values?
  2000-12-28 22:00 How to trim values? jkakar@expressus.com
@ 2000-12-28 22:45 ` Oliver Elphick <olly@lfix.co.uk>
  2000-12-30 10:34   ` Re: How to trim values? Karel Zak <zakkr@zf.jcu.cz>
  0 siblings, 1 reply; 3+ messages in thread

From: Oliver Elphick @ 2000-12-28 22:45 UTC (permalink / raw)
  To: jkakar@expressus.com; +Cc: pgsql-sql

jkakar@expressus.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)

-- 
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47  6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "For God shall bring every work into judgment, 
      with every secret thing, whether it be good, or  
      whether it be evil."               Ecclesiastes 12:14 





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: How to trim values?
  2000-12-28 22:00 How to trim values? jkakar@expressus.com
  2000-12-28 22:45 ` Re: How to trim values? Oliver Elphick <olly@lfix.co.uk>
@ 2000-12-30 10:34   ` Karel Zak <zakkr@zf.jcu.cz>
  0 siblings, 0 replies; 3+ messages in thread

From: Karel Zak @ 2000-12-30 10:34 UTC (permalink / raw)
  To: Oliver Elphick <olly@lfix.co.uk>; +Cc: jkakar@expressus.com; pgsql-sql

On Thu, 28 Dec 2000, Oliver Elphick wrote:

> jkakar@expressus.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




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2000-12-30 10:34 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-12-28 22:00 How to trim values? jkakar@expressus.com
2000-12-28 22:45 ` Oliver Elphick <olly@lfix.co.uk>
2000-12-30 10:34   ` Karel Zak <zakkr@zf.jcu.cz>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox