Go4Expert

Go4Expert (http://www.go4expert.com/)
-   ASP (http://www.go4expert.com/forums/asp/)
-   -   Cutting a string down to size. (http://www.go4expert.com/forums/cutting-string-size-t4190/)

CaJack 7May2007 00:17

Cutting a string down to size.
 
Hi,
I'm having trouble displaying numbers like 10.9900 as 10.99. My sql database holds the numbers such as 10.9900 and when I'm using my site i want the page to retrieve the number but cut the 2 zeros off of the end. I've found a way of cutting out the first 2 numbers...

Code:

testString.Substring(testString.length - 2)
But i cant seem to make it cut out the last 2 numbers, can anyone help?
Thanks.

pradeep 7May2007 00:25

Re: Cutting a string down to size.
 
Try this
Code: CSharp

testString.ToString("n2");


CaJack 7May2007 00:56

Re: Cutting a string down to size.
 
Hi, That works perfect. What does it do exactly? does it do something on the database level? I've never come across this before and its quite interesting. Thanks.

pradeep 7May2007 10:06

Re: Cutting a string down to size.
 
That just formats the string to have 2 decimal places, simple! :-D


All times are GMT +5.5. The time now is 19:21.