How to convert number to char without decimal dot using Oracle TO_CHAR()

Viewed 207

I need to print the following number wiithout the decimal dot but keeping the two decimal places:

2000.50 to '000000200050'

Any ideas?

3 Answers

can you try
LPAD(col*100,12,'0')

This is going to pad data with 0 and make sure this is a 12 char string.

you want to convert a number to string, here is a way to do this by padding with 0 up and till a total length of 12 char

select lpad(2000.50*100,12,'0') 
  from dual

The below should solve your problem

with inputs as
(
    select 2000.50 as num from dual
)
select  num, to_char(num*100, 'fm000000000000') as new_num
from    inputs

enter image description here

Related