question

dbkid avatar image
dbkid asked

How to convert number to string ?

We have functions for converting date to char and vice versa.

Do we have any function in oracle which converts number to string?

string
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
KillerDBA avatar image
KillerDBA answered

The function to_char will do it. Here's an example:

SELECT '$' || to_char (3.14159) FROM dual;

Or you can use CAST, which is in the ANSI Standard:

SELECT cast (3.14159 AS VARCHAR2(20)) FROM dual;

The to_char function allows formatting:

SELECT To_Char(0,'$99,990.00') FROM dual;

And it will convert dates with formatting, too:

SELECT To_Char(current_date,'DDMMYYYY') FROM dual;
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

dbkid avatar image dbkid commented ·
Awesome reply. Thanks a lot dba.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.