Re: [GENERAL] casting float8 type - Mailing list pgsql-general

From Ulf Mehlig
Subject Re: [GENERAL] casting float8 type
Date
Msg-id 199811050805.JAA01821@uni-bremen.de
Whole thread Raw
In response to casting float8 type  (Bob Dusek <bobd@palaver.net>)
List pgsql-general
Bob Dusek <bobd@palaver.net> wrote:

> How would I go about converting a value of type 'float8' to a value
> of type 'int'?  It's probably not possible to do a straight
> conversion of a float to an int, but is there a truncate, or a
> rounding function that I could use?  I couldn't find such a thing in
> my search.

in a table/class `tbl' with an float attribute `fl' of my 6.3.2 database,
the following works:

    select cast(fl as int4) from tbl;

Hope it helps!

Ulf

--
======================================================================
 %%%%%            Ulf Mehlig              <ulf.mehlig@uni-bremen.de>
   %%%%!%%%       Projekt "MADAM"         <umehlig@uni-bremen.de>
%%%% %!% %%%%     ----------------------------------------------------
 ---| %%%         MADAM:  MAngrove    |  Center for Tropical Marine
    ||--%!%              Dynamics     |  Biology
    ||                  And           |  Fahrenheitstrasse 1
 _ /||\_/\_            Management     |
/  /    \  \ ~~~~~~~~~~~~~~~~~        |  28359 Bremen/Germany
  ~~~~~~~~~~~~~~~~~~~~

pgsql-general by date:

Previous
From: Constantin Teodorescu
Date:
Subject: Rules aren't saved by pg_dump !!!
Next
From: Joe Fisher
Date:
Subject: Help with PostgreSQL...