Home » SQL & PL/SQL » SQL & PL/SQL » display two digits after decimal point,
display two digits after decimal point, [message #435252] Tue, 15 December 2009 06:27 Go to next message
mohan1760
Messages: 59
Registered: June 2008
Member
i want to display two digits after decimal point,
i am trying

Select to_number('1234.64', '9999.9')
from dual

showing error as

ORA-01722: invalid number

Thanks in advance..
Re: display two digits after decimal point, [message #435253 is a reply to message #435252] Tue, 15 December 2009 06:30 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
You need to use TO_CHAR, with the appropriate format mask
Re: display two digits after decimal point, [message #435255 is a reply to message #435253] Tue, 15 December 2009 06:34 Go to previous messageGo to next message
mohan1760
Messages: 59
Registered: June 2008
Member


Select to_char(1234.645, 9999.99)
from dual

giving

1234.65


why it is rounding...
Re: display two digits after decimal point, [message #435256 is a reply to message #435255] Tue, 15 December 2009 06:35 Go to previous messageGo to next message
Littlefoot
Messages: 20827
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
What would you want to get as a result, then?
Re: display two digits after decimal point, [message #435258 is a reply to message #435255] Tue, 15 December 2009 06:37 Go to previous messageGo to next message
Michel Cadot
Messages: 63808
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
why it is rounding...

Because it is how it is designed to work and this is documented, you just have to read the documentation before using a feature.

Regards
Michel
Re: display two digits after decimal point, [message #435259 is a reply to message #435256] Tue, 15 December 2009 06:38 Go to previous messageGo to next message
mohan1760
Messages: 59
Registered: June 2008
Member
Select to_char(1234.645, '9999.99')
from dual

should give output as

1234.64

not 1234.65
Re: display two digits after decimal point, [message #435262 is a reply to message #435259] Tue, 15 December 2009 06:41 Go to previous messageGo to next message
pablolee
Messages: 2813
Registered: May 2007
Location: Scotland
Senior Member
Then look up the TRUNC function in the documentation. (I would post a link to it, but I know that you know where it is)
Re: display two digits after decimal point, [message #435264 is a reply to message #435262] Tue, 15 December 2009 06:45 Go to previous messageGo to next message
mohan1760
Messages: 59
Registered: June 2008
Member
Select trunc(1234.645, '9999.9')
from dual

giving output as

1234.645

Sad
Re: display two digits after decimal point, [message #435265 is a reply to message #435264] Tue, 15 December 2009 06:47 Go to previous messageGo to next message
pablolee
Messages: 2813
Registered: May 2007
Location: Scotland
Senior Member
Meaning that you have clearly not bothered your 4rse about going and reading the documentation.
Well done, you get the User71408 award this month
Re: display two digits after decimal point, [message #435266 is a reply to message #435259] Tue, 15 December 2009 06:47 Go to previous messageGo to next message
Michel Cadot
Messages: 63808
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
should give output as

1234.64

not 1234.65

No, it should not.
It should round (and actually does) as it is how it is designed and implemented.

Regards
Michel
Re: display two digits after decimal point, [message #435267 is a reply to message #435265] Tue, 15 December 2009 06:48 Go to previous messageGo to next message
Michel Cadot
Messages: 63808
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
Well done, you get the User71408 award this month


./fa/449/0/

Michel
Re: display two digits after decimal point, [message #435268 is a reply to message #435266] Tue, 15 December 2009 06:49 Go to previous messageGo to next message
mohan1760
Messages: 59
Registered: June 2008
Member
then how can i display 1234.64
Re: display two digits after decimal point, [message #435269 is a reply to message #435268] Tue, 15 December 2009 06:53 Go to previous messageGo to next message
pablolee
Messages: 2813
Registered: May 2007
Location: Scotland
Senior Member
*Sigh* You can use the TRUNC function. Read the documentation to find out how to use it correctly.
Re: display two digits after decimal point, [message #435270 is a reply to message #435269] Tue, 15 December 2009 06:56 Go to previous messageGo to next message
mohan1760
Messages: 59
Registered: June 2008
Member
thanks pablolee...

micheal cadot there is nothing to laugh about...breaking rules of forum...
Re: display two digits after decimal point, [message #435272 is a reply to message #435270] Tue, 15 December 2009 07:04 Go to previous messageGo to next message
pablolee
Messages: 2813
Registered: May 2007
Location: Scotland
Senior Member
Glad to be of help. Can you remember to post your solution for others that do a search for this sort of topic. Cheers

[Updated on: Tue, 15 December 2009 07:05]

Report message to a moderator

Re: display two digits after decimal point, [message #435274 is a reply to message #435270] Tue, 15 December 2009 07:11 Go to previous messageGo to next message
Michel Cadot
Messages: 63808
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
micheal cadot there is nothing to laugh about

I disagree I think pablolee's remark is very funny.

Regards
Michel
Re: display two digits after decimal point, [message #435275 is a reply to message #435274] Tue, 15 December 2009 07:12 Go to previous messageGo to next message
pablolee
Messages: 2813
Registered: May 2007
Location: Scotland
Senior Member
Cheers Michel Wink
Re: display two digits after decimal point, [message #435288 is a reply to message #435274] Tue, 15 December 2009 07:38 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Michel Cadot wrote on Tue, 15 December 2009 14:11
Quote:
micheal cadot there is nothing to laugh about

I disagree I think pablolee's remark is very funny.

Regards
Michel

Wow, this must be a first time ever...

I totally agree with Michel!

[Edit: typo]

[Updated on: Tue, 15 December 2009 07:39]

Report message to a moderator

Re: display two digits after decimal point, [message #435602 is a reply to message #435288] Thu, 17 December 2009 01:29 Go to previous messageGo to next message
mohan1760
Messages: 59
Registered: June 2008
Member
sab pagal hai
Re: display two digits after decimal point, [message #435603 is a reply to message #435602] Thu, 17 December 2009 01:35 Go to previous messageGo to next message
BlackSwan
Messages: 24912
Registered: January 2009
Senior Member
mohan1760 wrote on Wed, 16 December 2009 23:29
sab pagal hai


Please translate into Engish.

[Updated on: Thu, 17 December 2009 01:36]

Report message to a moderator

Re: display two digits after decimal point, [message #435640 is a reply to message #435603] Thu, 17 December 2009 03:43 Go to previous messageGo to next message
pablolee
Messages: 2813
Registered: May 2007
Location: Scotland
Senior Member
BlackSwan wrote on Thu, 17 December 2009 07:35
mohan1760 wrote on Wed, 16 December 2009 23:29
sab pagal hai


Please translate into Engish.

i believe it means something like "You're all mad" (Thanks to my colleague Amruta for translating Smile
Re: display two digits after decimal point, [message #435641 is a reply to message #435603] Thu, 17 December 2009 03:43 Go to previous messageGo to next message
mohan1760
Messages: 59
Registered: June 2008
Member
Laughing
Re: display two digits after decimal point, [message #435644 is a reply to message #435641] Thu, 17 December 2009 03:52 Go to previous messageGo to next message
pablolee
Messages: 2813
Registered: May 2007
Location: Scotland
Senior Member
So did you manage to solve your 'issue' mohan?
Re: display two digits after decimal point, [message #435645 is a reply to message #435602] Thu, 17 December 2009 03:56 Go to previous messageGo to next message
delna.sexy
Messages: 941
Registered: December 2008
Location: Surat, The Diamond City
Senior Member
./fa/1579/0/

regards,
Delna
Re: display two digits after decimal point, [message #435679 is a reply to message #435252] Thu, 17 December 2009 05:56 Go to previous messageGo to next message
abes_nitya
Messages: 4
Registered: September 2006
Location: Noida
Junior Member
I think following code would help u...

select to_char('123','999990.99') from dual
Re: display two digits after decimal point, [message #435684 is a reply to message #435679] Thu, 17 December 2009 06:15 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
abes_nitya wrote on Thu, 17 December 2009 12:56
I think following code would help u...

select to_char('123','999990.99') from dual

Did you bother to read the thread?
Re: display two digits after decimal point, [message #435687 is a reply to message #435679] Thu, 17 December 2009 06:17 Go to previous messageGo to next message
pablolee
Messages: 2813
Registered: May 2007
Location: Scotland
Senior Member
And you would be stupendously wrong. Read the whole thread then try agaian (hint: Your best solution would be to post nothing as the correct solution has already been supplied and your solution is very wrong based on thne requirements)
Re: display two digits after decimal point, [message #435792 is a reply to message #435687] Fri, 18 December 2009 01:03 Go to previous messageGo to next message
mohan1760
Messages: 59
Registered: June 2008
Member
i have solved my problem
Re: display two digits after decimal point, [message #435794 is a reply to message #435792] Fri, 18 December 2009 01:06 Go to previous messageGo to next message
pablolee
Messages: 2813
Registered: May 2007
Location: Scotland
Senior Member
Once again, can you post the solution that you used so that people searching for this sort of topic may actually find it useful.
Re: display two digits after decimal point, [message #435943 is a reply to message #435794] Sat, 19 December 2009 07:02 Go to previous messageGo to next message
mohan1760
Messages: 59
Registered: June 2008
Member
what do you mean by..
Well done, you get the User71408 award this month
Re: display two digits after decimal point, [message #435944 is a reply to message #435943] Sat, 19 December 2009 07:03 Go to previous messageGo to next message
pablolee
Messages: 2813
Registered: May 2007
Location: Scotland
Senior Member
I'll tell you when you post your solution.
Re: display two digits after decimal point, [message #435947 is a reply to message #435943] Sat, 19 December 2009 10:23 Go to previous message
ramoradba
Messages: 2454
Registered: January 2009
Location: AndhraPradesh,Hyderabad,I...
Senior Member
mohan1760 wrote on Sat, 19 December 2009 18:32
what do you mean by..
Well done, you get the User71408 award this month



Read the forum guide lines.the seniors are to help us,Some times their words may be harsh,But the suggestions are valuable. Don't use Hindi comments.Smile

More importantly they just pointed you to read the document.Nothing serious on that.If you really got the solution post here so that it will help the other User when they got the same error/problem/requirement.

Good luck
sriram Smile


[Updated on: Sat, 19 December 2009 10:25]

Report message to a moderator

Previous Topic: Date format discrepancies
Next Topic: Problem in my package procedure in a select query
Goto Forum:
  


Current Time: Wed Sep 28 15:57:07 CDT 2016

Total time taken to generate the page: 0.07190 seconds