formating number

Discussion in 'ASP General' started by Jeff, Nov 9, 2006.

  1. Jeff

    Jeff Guest

    hey guys

    If i wish to show a decimal on a number, i can do this

    v2_score = formatnumber(v2_score1, 0)

    but how would i only show the 2 decimal places IF there is an actual
    remainder after the division?

    here is the script and stuff
    using sql db server

    v2_score1 = v_score / v_played
    v2_score = formatnumber(v2_score1, 0)

    v_score is an over all total in the db
    v_played is how many matches were played.

    any help please.... and thank you??
     
    Jeff, Nov 9, 2006
    #1
    1. Advertising

  2. Jeff

    MadMike42 Guest

    Use the MOD function,
    this will return the numbers after the point

    example
    a) 42/100 = 0.42
    b) 42 mod 100 = 42

    SO if you have a result to the MOD sum, you can show
    with the formatting, if no result, you can show with out the formatting

    Mike.

    "Jeff" <> wrote in message
    news:...
    > hey guys
    >
    > If i wish to show a decimal on a number, i can do this
    >
    > v2_score = formatnumber(v2_score1, 0)
    >
    > but how would i only show the 2 decimal places IF there is an actual
    > remainder after the division?
    >
    > here is the script and stuff
    > using sql db server
    >
    > v2_score1 = v_score / v_played
    > v2_score = formatnumber(v2_score1, 0)
    >
    > v_score is an over all total in the db
    > v_played is how many matches were played.
    >
    > any help please.... and thank you??
    >
     
    MadMike42, Nov 10, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rodrigo guerra

    automatic code formating...

    rodrigo guerra, Jul 5, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    359
    rodrigo guerra
    Jul 5, 2003
  2. Dmitri Manushin

    Formating text

    Dmitri Manushin, Aug 14, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    386
    Dmitri Manushin
    Aug 14, 2003
  3. John Carnahan

    Help on date formating

    John Carnahan, Nov 19, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    315
    Alvin Bruney
    Nov 19, 2003
  4. Robocop
    Replies:
    3
    Views:
    7,070
    Sean Berry
    Feb 26, 2004
  5. Jamie Fryatt

    number formating!

    Jamie Fryatt, Feb 10, 2004, in forum: ASP General
    Replies:
    2
    Views:
    102
    Jamie Fryatt
    Feb 10, 2004
Loading...

Share This Page