1

How can I convert a string 17,74320512 to a double precision in PostgreSQL ?

I tried:

select cast(`17,74320512` as double precision);

ERROR: invalid syntax for double precision type: '17,74320512'

But i can not change format of the number(17,74320512) because i imported it from .txt file

1 Answer 1

1

Use to_number() and chose the format that best suits your strings and locale, e.g.

SELECT 
  to_number('17,74320512','999D99999999'),
  to_number('17,74320512','999D99999999')::double precision;

  to_number  |  to_number  
-------------+-------------
 17.74320512 | 17.74320512
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.