Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Putting a decimal in results - ASP?

Options
  • 21-04-2008 10:36am
    #1
    Registered Users Posts: 1,477 ✭✭✭


    Does anyone know how to take a returned value from a MYSQL DB, in ASP and always place a decimal point two digits to the left?

    I have a very simple ASP page that connects to a MYSQL DB and returns a value, below is the code:

    userid = Request.Form("USERNAME")
    objConn.Open(sConnection)
    Set objRS = objConn.Execute("SELECT * FROM tbluseracct where actUserID = '" & USERID &"'")

    The value come back fine but its held in interger format, i.e 1435 would mean €14.35. Does anyone know a simple way to take this value and format it correctly in the output? I can add the € sign fine but I am not sure about adding the decimal in 2 place every time?

    Newbie BTW, in case I insult anyone!


Comments

  • Registered Users Posts: 706 ✭✭✭DJB


    you can do something like this within your loop:

    sValue = rs("Value") 'this gets the value of 1435 into a variable. amend to suit your naming conventions
    sValueNew = "&euro" & Left(sValue,len(sValue)-2) & "." & Right(sValue,2)

    sValueNew now has the formatted value in it.

    HTH

    Dave


  • Registered Users Posts: 1,477 ✭✭✭azzeretti


    DJB wrote: »
    you can do something like this within your loop:

    sValue = rs("Value") 'this gets the value of 1435 into a variable. amend to suit your naming conventions
    sValueNew = "&euro" & Left(sValue,len(sValue)-2) & "." & Right(sValue,2)

    sValueNew now has the formatted value in it.

    HTH

    Dave

    Thanks for this, but one question....will this work for a result like 10000 that should be 100 euro? Thanks


  • Registered Users Posts: 6,465 ✭✭✭MOH


    Just divide it by 100?


  • Registered Users Posts: 2,931 ✭✭✭Ginger


    Why not try the uber sekrit FormatCurrency function...

    http://www.w3schools.com/vbscript/func_formatcurrency.asp

    First divide by 100 and then apply the format


Advertisement