1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Cutting a string down to size.

Discussion in 'ASP' started by CaJack, May 6, 2007.

  1. CaJack

    CaJack New Member

    Joined:
    Mar 21, 2007
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    Try this
    Code:
    testString.ToString("n2");
    
     
  3. CaJack

    CaJack New Member

    Joined:
    Mar 21, 2007
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  4. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    That just formats the string to have 2 decimal places, simple! :-D
     

Share This Page