473,325 Members | 2,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Displaying data to 2 decimal points

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.
Jul 19 '05 #1
10 5642
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"
Jul 19 '05 #2
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" <re******@NOyahoo.SPAMcom> wrote in message
news:O9*************@tk2msftngp13.phx.gbl...
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"

Jul 19 '05 #3
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"
Jul 19 '05 #4
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;DATABA SE=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" <re******@NOyahoo.SPAMcom> wrote in message
news:#$*************@TK2MSFTNGP10.phx.gbl...
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"

Jul 19 '05 #5
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"
Jul 19 '05 #6
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" <re******@NOyahoo.SPAMcom> wrote in message
news:uM**************@TK2MSFTNGP10.phx.gbl...
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"

Jul 19 '05 #7
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"
Jul 19 '05 #8
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"
Jul 19 '05 #9
Exellent, the session LCID worked a treat,

Thanks for the wonderful service you ppl provide

--
G

www.bradflack.com

Please remove ANTI and SPAM from my
email address before sending me an email.
"Bob Barrows" <re******@NOyahoo.SPAMcom> wrote in message
news:eC**************@TK2MSFTNGP09.phx.gbl...
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"

Jul 19 '05 #10
U guys are amazing. I am very new with asp. i found thses information very useful.

Thanks a LOT :)
Apr 21 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Rahul Chatterjee | last post by:
Hello All I have an asp page in which I am performing the following 1. Querying a database view 2. Returning rows in to a recordset. 3. Looping thru the recordset and printing the data 4....
5
by: Michael Hill | last post by:
Hi, folks. I am writing a Javascript program that accepts (x, y) data pairs from a text box and then analyzes that data in various ways. This is my first time using text area boxes; in the past,...
4
by: pmud | last post by:
Hi, I have an image which resides on a different server...on data server. I am developing on Development server. When I use the image URLin my ASP.Net web page as ...
1
by: .Net Sports | last post by:
the below itemdatabound function works , displays all the grand totals in the footer control of the datagrid: private void dglvboard_ItemDataBound(object sender,...
0
by: Sam | last post by:
I am trying to use a Simple form with 3 fields from SQL NorthWind Database (Order Details Table with 3 Fields. - OrderId, ProductId and Unit Price). The Field Unit Price has a data type of 'Money...
0
by: Sam | last post by:
Folks.. I am trying to use a Simple form with 3 fields from SQL NorthWind Database (Order Details Table with 3 Fields. - OrderId, ProductId and Unit Price). The Field Unit Price has a data...
4
by: Ronald S. Cook | last post by:
We're designing the data model for a project. The app will be in .NET, the database will be in SQL Server 2005. I'm a little confused on type conversion between the two and which I should...
20
by: D.M. Procida | last post by:
I'm trying to find a guide for the formatting and presentation of numbers in web pages, which will answer questions along the lines of what if anything to use as separators in large figures, how to...
1
by: drwigginton | last post by:
I have created several bar charts in MS Access using query results to provide the data for the chart. I added data tables to the charts to show the actual values. My problem is that one of the fields...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.