to_char: convert number to char : to_char « String Functions « PostgreSQL






to_char: convert number to char


postgres=#
postgres=#
postgres=# CREATE TABLE money_example (
postgres(#             money_cash money,
postgres(#             numeric_cash numeric(10,2));
CREATE TABLE
postgres=#
postgres=# INSERT INTO money_example VALUES ('$12.24', 12.24);
INSERT 0 1
postgres=#
postgres=#
postgres=# SELECT money_cash, '$' || ltrim(to_char(numeric_cash, '9999.99'))
postgres-#        AS numeric_cashified
postgres-#        FROM money_example;
 money_cash | numeric_cashified
------------+-------------------
     $12.24 | $12.24
(1 row)

postgres=#
postgres=# drop table money_example;
DROP TABLE
postgres=#
           
       








Related examples in the same category

1.to_char(start_date, 'YYYY-MM-DD HH24:MI:SS')
2.to_char(123456789, '999G999G999D99')
3.to_char(123456789, '999999999')
4.to_char(123456789, '00999999999')
5.If space is not enough for display
6.to_char(1.0, '9th "Place"')