Home » SQL & PL/SQL » SQL & PL/SQL » converting a number to 2 decimal places
converting a number to 2 decimal places [message #21193] Wed, 17 July 2002 13:21 Go to next message
Tracy
Messages: 43
Registered: January 2000
Member
Can you tell me how to convert a whole number to 2 decimal places? For example, a value of 1 cent is stored in the database as 1. I need to take 1 and convert it to 0.01

thanks,
Tracy
Re: converting a number to 2 decimal places [message #21194 is a reply to message #21193] Wed, 17 July 2002 13:27 Go to previous messageGo to next message
Tracy
Messages: 43
Registered: January 2000
Member
P.S. Dividing by zero works fine for the number 1. However, if I have the number 2200, I want to display 22.00, not just 22. In the latter case, division by 100 doesn't work perfectly as it drops off any zeros after the decimal point.
Re: converting a number to 2 decimal places [message #21196 is a reply to message #21194] Wed, 17 July 2002 13:38 Go to previous messageGo to next message
Gary Chambers
Messages: 1
Registered: July 2002
Junior Member
select to_char(1/100, '0.99') from dual;
select to_char(2200/100, '09.99') from dual;
Re: converting a number to 2 decimal places [message #21211 is a reply to message #21194] Thu, 18 July 2002 05:09 Go to previous message
Tracy
Messages: 43
Registered: January 2000
Member
Thank you!
Previous Topic: automating stored procedure
Next Topic: Update Cursors and their locks
Goto Forum:
  


Current Time: Fri Apr 26 20:19:42 CDT 2024