Displaying data to 2 decimal points

Discussion in 'ASP General' started by Guy Hocking, Mar 7, 2004.

  1. Guy Hocking

    Guy Hocking Guest

    Hi there,

    I have an ASP/SQL 7 application that rips data from SQL Views onto an ASP
    page.
    I have a money column in a SQL table that contains money income values.

    When data is input to this field it needs to be displayed as money (to 2
    decimal places - 10.00 or 7.60)
    However, this only seems to be occurring when the user puts in the extra 0,
    and if 7.6 is entered, it is still displayed as 7.6

    I need all data to be displayed as money values (and it is selected as money
    in SQL), so is there any way (either in the table design, View design, or
    display on the ASP page) to get the data to 2 decimal places, no matter
    what?

    Thanks for you help, in advance

    --
    G

    www.bradflack.com

    Please remove ANTI and SPAM from my
    email address before sending me an email.
     
    Guy Hocking, Mar 7, 2004
    #1
    1. Advertising

  2. Guy Hocking

    Bob Barrows Guest

    Guy Hocking wrote:
    > Hi there,
    >
    > I have an ASP/SQL 7 application that rips data from SQL Views onto an
    > ASP page.
    > I have a money column in a SQL table that contains money income
    > values.
    >
    > When data is input to this field it needs to be displayed as money
    > (to 2 decimal places - 10.00 or 7.60)
    > However, this only seems to be occurring when the user puts in the
    > extra 0, and if 7.6 is entered, it is still displayed as 7.6
    >
    > I need all data to be displayed as money values (and it is selected
    > as money in SQL), so is there any way (either in the table design,
    > View design, or display on the ASP page) to get the data to 2 decimal
    > places, no matter what?
    >
    > Thanks for you help, in advance


    Use one of these vbscript functions:
    FormatCurrency
    FormatNumber

    HTH,
    Bob Barrows

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows, Mar 7, 2004
    #2
    1. Advertising

  3. Guy Hocking

    Guy Hocking Guest

    Hi,

    Thanks for the response -

    Any examples of the functions in my scenario?

    Cheers

    --
    G

    www.bradflack.com

    Please remove ANTI and SPAM from my
    email address before sending me an email.
    "Bob Barrows" <> wrote in message
    news:...
    > Guy Hocking wrote:
    > > Hi there,
    > >
    > > I have an ASP/SQL 7 application that rips data from SQL Views onto an
    > > ASP page.
    > > I have a money column in a SQL table that contains money income
    > > values.
    > >
    > > When data is input to this field it needs to be displayed as money
    > > (to 2 decimal places - 10.00 or 7.60)
    > > However, this only seems to be occurring when the user puts in the
    > > extra 0, and if 7.6 is entered, it is still displayed as 7.6
    > >
    > > I need all data to be displayed as money values (and it is selected
    > > as money in SQL), so is there any way (either in the table design,
    > > View design, or display on the ASP page) to get the data to 2 decimal
    > > places, no matter what?
    > >
    > > Thanks for you help, in advance

    >
    > Use one of these vbscript functions:
    > FormatCurrency
    > FormatNumber
    >
    > HTH,
    > Bob Barrows
    >
    > --
    > Microsoft MVP - ASP/ASP.NET
    > Please reply to the newsgroup. This email account is my spam trap so I
    > don't check it very often. If you must reply off-line, then remove the
    > "NO SPAM"
    >
    >
     
    Guy Hocking, Mar 7, 2004
    #3
  4. Guy Hocking

    Bob Barrows Guest

    Guy Hocking wrote:
    > Hi,
    >
    > Thanks for the response -
    >
    > Any examples of the functions in my scenario?
    >

    Given that you have not provided any details about your scenario (where are
    you having a problem? Connecting to the database? Retrieving data in a
    recordset? Reading the data from the fields in the recordset?), I can't
    offer any examples beyond what is shown in the online documentation. Perhaps
    that is what you need ... ? Here is a link:

    http://tinyurl.com/7rk6

    Just look up the functions in there once you have downloaded and installed
    it. A Google search or a search of www.aspfaq.com could also provide you
    with some examples of their use.


    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows, Mar 7, 2004
    #4
  5. Guy Hocking

    Guy Hocking Guest

    Hi there,

    Apologies for that.....

    I have downloaded the script docs, and it is very useful, ta.....
    But i was wondering how i would incorporate this into my SELECT statement?

    See entire code below -
    *******
    <%
    Dim strConnect, DataConnection

    Set DataConnection = Server.CreateObject("ADODB.Connection")
    strConnect = "DRIVER={SQL
    Server};SERVER=server;UID=user;PWD=password;DATABASE=database"
    DataConnection.Open strConnect
    %>
    <%
    Dim RS
    Set RS = DataConnection.Execute("SELECT col2, currencycol FROM view
    WHERE col1='" & Session("listbox") & "'")
    do until RS.EOF

    <a href= "page.asp?col1=<% =RS("col2")%>"><% =RS("col2")%></a>

    <% =RS("currencycol")%>

    <% RS.MoveNext
    Loop %>
    *******

    How/where can i format the "currencycol" ???

    Thanks again

    --
    G

    www.bradflack.com

    Please remove ANTI and SPAM from my
    email address before sending me an email.
    "Bob Barrows" <> wrote in message
    news:#$...
    > Guy Hocking wrote:
    > > Hi,
    > >
    > > Thanks for the response -
    > >
    > > Any examples of the functions in my scenario?
    > >

    > Given that you have not provided any details about your scenario (where

    are
    > you having a problem? Connecting to the database? Retrieving data in a
    > recordset? Reading the data from the fields in the recordset?), I can't
    > offer any examples beyond what is shown in the online documentation.

    Perhaps
    > that is what you need ... ? Here is a link:
    >
    > http://tinyurl.com/7rk6
    >
    > Just look up the functions in there once you have downloaded and installed
    > it. A Google search or a search of www.aspfaq.com could also provide you
    > with some examples of their use.
    >
    >
    > Bob Barrows
    > --
    > Microsoft MVP - ASP/ASP.NET
    > Please reply to the newsgroup. This email account is my spam trap so I
    > don't check it very often. If you must reply off-line, then remove the
    > "NO SPAM"
    >
    >
     
    Guy Hocking, Mar 7, 2004
    #5
  6. Guy Hocking

    Bob Barrows Guest

    Guy Hocking wrote:
    > Hi there,
    >
    > Apologies for that.....
    >
    > I have downloaded the script docs, and it is very useful, ta.....
    > But i was wondering how i would incorporate this into my SELECT
    > statement?
    >

    Why do you need to put it in your Select statement? Just use the appropriate
    function when writing the results to your page. Like this:

    > <% =FormatCurrency(RS("currencycol"),2)%>
    >



    If you really want to do it in your query, look up the CONVERT function in
    SQL BOL.

    Here is an example for you to run in QA:

    select convert(varchar(20),cast(45.1213 as money))

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows, Mar 7, 2004
    #6
  7. Guy Hocking

    Guy Hocking Guest

    Wicked, that works great, 1 thing -

    Its coming up in dollars $
    How can i get it to do it in pounds £

    Cheers

    --
    G

    www.bradflack.com

    Please remove ANTI and SPAM from my
    email address before sending me an email.
    "Bob Barrows" <> wrote in message
    news:...
    > Guy Hocking wrote:
    > > Hi there,
    > >
    > > Apologies for that.....
    > >
    > > I have downloaded the script docs, and it is very useful, ta.....
    > > But i was wondering how i would incorporate this into my SELECT
    > > statement?
    > >

    > Why do you need to put it in your Select statement? Just use the

    appropriate
    > function when writing the results to your page. Like this:
    >
    > > <% =FormatCurrency(RS("currencycol"),2)%>
    > >

    >
    >
    > If you really want to do it in your query, look up the CONVERT function in
    > SQL BOL.
    >
    > Here is an example for you to run in QA:
    >
    > select convert(varchar(20),cast(45.1213 as money))
    >
    > Bob Barrows
    > --
    > Microsoft MVP - ASP/ASP.NET
    > Please reply to the newsgroup. This email account is my spam trap so I
    > don't check it very often. If you must reply off-line, then remove the
    > "NO SPAM"
    >
    >
     
    Guy Hocking, Mar 7, 2004
    #7
  8. Guy Hocking

    Bob Barrows Guest

    Guy Hocking wrote:
    > Wicked, that works great, 1 thing -
    >
    > Its coming up in dollars $
    > How can i get it to do it in pounds £
    >

    It depends on which one you did. I suspect you're talking about
    FormatCurrency rather than the T-SQL CONVERT, so add this line of code to
    your page:

    session.LCID=2057

    The problem is that the Regional Settings for the IUSR account are the
    default (US) settings. You can override that with the LCID property.

    Bob Barrows
    PS. If you were talking about the CONVERT alternative, simply prepend a
    pound symbol:

    select char(163) + convert(varchar(20),cast(45.1213 as money))
    or
    select '&pound;' + convert(varchar(20),cast(45.1213 as money))



    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows, Mar 7, 2004
    #8
  9. Guy Hocking

    Bob Barrows Guest

    Bob Barrows wrote:
    > Guy Hocking wrote:
    >> Wicked, that works great, 1 thing -
    >>
    >> Its coming up in dollars $
    >> How can i get it to do it in pounds £
    >>

    > It depends on which one you did. I suspect you're talking about
    > FormatCurrency rather than the T-SQL CONVERT, so add this line of
    > code to your page:
    >
    > session.LCID=2057


    Sorry, I should have said
    Response.LCID =2057

    The Session setting will affect all pages accessed during the session,
    unless overridden with the Response setting. If you use the Session setting,
    it should be done in global.asa.

    Bob Barrows
    PS. I just realized you included the sql server setup group in your
    crosspost. That did not seem to be an appropriate group so I've just removed
    it from this reply. If any sql server group was relevant, it would have been
    ..programming.

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows, Mar 7, 2004
    #9
    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. Sam
    Replies:
    1
    Views:
    8,837
    Prnda76
    Feb 11, 2010
  2. Replies:
    1
    Views:
    2,500
  3. Byte

    Working with decimal points

    Byte, Apr 8, 2006, in forum: Python
    Replies:
    8
    Views:
    410
    Fredrik Lundh
    Apr 8, 2006
  4. Pp

    Precision upto n decimal points

    Pp, Dec 4, 2011, in forum: C Programming
    Replies:
    10
    Views:
    733
    gwowen
    Dec 5, 2011
  5. Replies:
    8
    Views:
    152
Loading...

Share This Page