473,386 Members | 1,819 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,386 software developers and data experts.

Update Column to add Decimal Point

Hi all,

have a 'money' field in the SQL 2000 table that users enter 200 (for example
which represents £2.00) without the decimal point, what I need is to have a
command or something that adds the decimal point before the last 2 digits,
so user enters 200 and the value stored in the table is 2.00 bearing in mind
that this value could be anything from 1.00 to 50.00.

The user enters the data from an asp page on a touch screen device.

Regards
Simon

--
Simon Gare
The Gare Group Limited

website: www.thegaregroup.co.uk
website: www.privatehiresolutions.co.uk
Apr 16 '07 #1
3 2912
Simon Gare wrote on 16 apr 2007 in
microsoft.public.inetserver.asp.general:
Hi all,

have a 'money' field in the SQL 2000 table that users enter 200 (for
example which represents £2.00) without the decimal point, what I need
is to have a command or something that adds the decimal point before
the last 2 digits, so user enters 200 and the value stored in the
table is 2.00 bearing in mind that this value could be anything from
1.00 to 50.00.

The user enters the data from an asp page on a touch screen device.
<script language='jscript' runat='server'>

function addDecPoint(x){
var s = (x<0)?'-':'';
x = Math.abs(x);
x=(x<100)?((x+1000)+'').substr(1):''+x;
return s + x.replace(/(\d\d)$/,'.$1');
};

</script>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Apr 16 '07 #2
ok,

field in the table is called car_park the asp page is slightly more
difficult as the user enters the data via a .swf file. can this be run as a
command somewhere else, below is the code on the asp file (bearing in mind
that there is not actual text field here) some more assistance would be
appreciated.

Dim id, waiting, carPark
Dim driverNo, sId

Dim sql, conn

Dim sResponse

sResponse = ""

id = Request.Form("id")
waiting = Request.Form("waiting")
carPark = Request.Form("carPark")

driverNo = Request.Form("driverNo")
sId = Request.Form("sId")

If (Len(id) = 0 OR NOT IsNumeric(id)) OR Len(waiting) = 0 OR Len(carPark)
= 0 OR Len(driverNo) = 0 OR Len(sId) = 0 Then
Response.Write("end_done=ERROR")
Response.End()
End If

Set conn = Server.CreateObject("ADODB.Connection")
conn.Open g_connectionString

' Updating booking_form...

sql = "UPDATE booking_form SET waiting_in_minutes='" & waiting & "',
car_park='" & carPark & "', time_cleared=GETDATE(), allocated='COMPLETED'
WHERE ID=" & id

conn.Execute(sql)
<script language='jscript' runat='server'>

function addDecPoint(x){
var s = (x<0)?'-':'';
x = Math.abs(x);
x=(x<100)?((x+1000)+'').substr(1):''+x;
return s + x.replace(/(\d\d)$/,'.$1');
};

</script>

Apr 16 '07 #3
Simon Gare wrote on 16 apr 2007 in
microsoft.public.inetserver.asp.general:

[Please do not toppost on usenet]
Topposting corrected

>have a 'money' field in the SQL 2000 table that users enter 200 (for
example which represents £2.00) without the decimal point, what I
need is to have a command or something that adds the decimal point
before the last 2 digits, so user enters 200 and the value stored in
the table is 2.00 bearing in mind that this value could be anything
from 1.00 to 50.00.
><script language='jscript' runat='server'>

function addDecPoint(x){
var s = (x<0)?'-':'';
x = Math.abs(x);
x=(x<100)?((x+1000)+'').substr(1):''+x;
return s + x.replace(/(\d\d)$/,'.$1');
};

</script>
ok,

field in the table is called car_park the asp page is slightly more
difficult as the user enters the data via a .swf file. can this be run
as a command somewhere else, below is the code on the asp file
(bearing in mind that there is not actual text field here) some more
assistance would be appreciated.

Dim id, waiting, carPark
Dim driverNo, sId

Dim sql, conn

Dim sResponse

sResponse = ""

id = Request.Form("id")
waiting = Request.Form("waiting")
carPark = Request.Form("carPark")

driverNo = Request.Form("driverNo")
sId = Request.Form("sId")

If (Len(id) = 0 OR NOT IsNumeric(id)) OR Len(waiting) = 0 OR
Len(carPark)
= 0 OR Len(driverNo) = 0 OR Len(sId) = 0 Then
Response.Write("end_done=ERROR")
Response.End()
End If

Set conn = Server.CreateObject("ADODB.Connection")
conn.Open g_connectionString

' Updating booking_form...

sql = "UPDATE booking_form SET waiting_in_minutes='" & waiting &
"',
car_park='" & carPark & "', time_cleared=GETDATE(),
allocated='COMPLETED' WHERE ID=" & id

conn.Execute(sql)
Where is your money field you specified in the original posting I added
above???

And you specified a value coming FROM a database, so I would need to se a
SELECT SQL, not an UPDATE SQL, meseems.

================================================== =

You can easily change the integer cents value coming from that field in
vbscript and write that:

<% 'vbs
response.write "£ " & addDecPoint(centsValueFromDatabase)
%>

The jscript part can be put anywhere in the vbs-using asp page,
usually I put it at the bottom.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Apr 16 '07 #4

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

Similar topics

10
by: sqlgoogle | last post by:
Hi I'm trying to update a db based on the select statement which has ORDER BY in it. And due to that I'm getting error which states that Server: Msg 1033, Level 15, State 1, Line 13 The ORDER...
0
by: cwbp17 | last post by:
Have a datagrid that displays the price column in this format $12,400.00 from a table. Went to the Property Builder of the datagrid and selected the Price column and changed the Data formatting...
1
by: meyvn77 | last post by:
I'm new to adp w/ sql server but I have to use it on a project i'm doing... One of the MUSTS for this project is the ability to update a 00 - 09 text value with the appropriate text description...
2
by: Joe Fetters via .NET 247 | last post by:
Have googled and read the VS.NET documentation can't seem to getthe answer to the following. Environment: Framework 1.1 VB.NET WinForm Access database Using all automagic tools (DataAdapter...
5
by: cwbp17 | last post by:
Hi all, Have a datagrid that displays the price column of a table. Went to the Datagrid's Property builder and set the 'Data Formatting expression' for the PRICE column to {0:c}, so that the...
1
by: BabuMan | last post by:
Hi, I have a FormView control on a page which is bound to a SQLDataSource table. Everything works fine except for the "Update". I get an InvalidCastException. The problem only seems to surface...
4
by: =?Utf-8?B?QmFidU1hbg==?= | last post by:
Hi, I have a GridView and a SqlDataSource controls on a page. The SqlDataSource object uses stored procedures to do the CRUD operations. The DataSource has three columns one of which -...
3
by: Sam Durai | last post by:
A simple update involving two small tables takes 45 minutes to complete. I would appreciate if you can kindly help me to understand the root cause of this slowness. Users would be happy if I can...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.