float to int

Lists: pgsql-general
From: "Charles(dot)Hou" <ivan(dot)hou(at)msa(dot)hinet(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: float to int
Date: 2007-11-12 06:33:06
Message-ID: 1194849186.336562.29020@i13g2000prf.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

how can i get the int value using the sql language? like this,

"select cost from my_money_table " , the data type of cost is float.


From: Edoardo Panfili <edoardo(at)aspix(dot)it>
To: "Charles(dot)Hou" <ivan(dot)hou(at)msa(dot)hinet(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: float to int
Date: 2007-11-12 15:10:47
Message-ID: 47386CF7.2060608@aspix.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Charles.Hou ha scritto:
> how can i get the int value using the sql language? like this,
>
> "select cost from my_money_table " , the data type of cost is float.
>
take a look at
http://www.postgresql.org/docs/8.2/static/sql-expressions.html
CAST ( expression AS type )
expression::type

Edoardo

--
Jabber: edoardopa(at)talk(dot)google(dot)com
tel: 075 9142766


From: Lew <lew(at)lwsc(dot)ehost-services(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: float to int
Date: 2007-11-12 19:54:37
Message-ID: 4oSdncE2-KHjMqXanZ2dnUVZ_ufinZ2d@comcast.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Edoardo Panfili wrote:
> Charles.Hou ha scritto:
>> how can i get the int value using the sql language? like this,
>>
>> "select cost from my_money_table " , the data type of cost is float.
>>
> take a look at
> http://www.postgresql.org/docs/8.2/static/sql-expressions.html
> CAST ( expression AS type )
> expression::type

Incidentally, float is about the worst data type to represent monetary amounts
that one can choose.

--
Lew