I need to convert a value of Double Precision to Bigint with PostgreSQL. How can I do that?

I have tried with to_bigint(myvalue) but that function didn't exist.

1 Answer 1


There are two ways to typecast in Postgres:

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.

  • 2
    @eevar Just a note from the docs, the rounding functions return type is "same as input," so if the type is important, casts are required. Commented Aug 19, 2015 at 21:34
  • 1
    Looks like CAST actually does rounding Commented Mar 17, 2016 at 19:34
  • 1
    Is there a doc which function is applied when SELECT 4.7::int? Commented Mar 6, 2020 at 12:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.