snippetsqlCritical
How can I convert from Double Precision to Bigint with PostgreSQL?
Viewed 0 times
postgresqlcanconvertwithprecisiondoublehowbigintfrom
Problem
I need to convert a value of Double Precision to Bigint with PostgreSQL. How can I do that?
I have tried with
I have tried with
to_bigint(myvalue) but that function didn't exist.Solution
There are two ways to typecast in Postgres:
You either do it the SQL standard way:
or you could use the Postgres-specific cast operator:
You might also want to consider the various rounding functions.
You either do it the SQL standard way:
select cast(3.141593 as bigint);or you could use the Postgres-specific cast operator:
:: select (3.141593 :: bigint);You might also want to consider the various rounding functions.
Code Snippets
select cast(3.141593 as bigint);select (3.141593 :: bigint);Context
StackExchange Database Administrators Q#3429, answer score: 50
Revisions (0)
No revisions yet.