0

Ok I am converting from SQL Server to PostgreSQL. I am having trouble with some to_char.

CASE LENGTH(LTRIM(RTRIM(to_char(floor(_FloatValue)))))
    WHEN 1 THEN '0' || LENGTH(LTRIM(RTRIM(TO_CHAR(floor(_FloatValue))))) || ':'
    ELSE LENGTH(LTRIM(RTRIM(TO_CHAR(FLOOR(_FloatValue))))) || ':'

I'm getting this error

   [2015-11-10 15:40:20] [42883] ERROR: function to_char(double precision) does not exist
   Hint: No function matches the given name and argument types. You might need to add explicit type casts.
   Where: PL/pgSQL function formatfloattohoursminutes(double precision) line 10 at RETURN

Any help would be great.

1
  • 1) Show sql server code 2) Tell what it do Commented Nov 11, 2015 at 15:48

1 Answer 1

1

It looks like you want to left pad with zeros:

select to_char(_FloatValue, '09.99');

http://www.postgresql.org/docs/current/static/functions-formatting.html#FUNCTIONS-FORMATTING-TABLE

http://www.postgresql.org/docs/current/static/functions-formatting.html#FUNCTIONS-FORMATTING-NUMERIC-TABLE

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.