473,666 Members | 2,296 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2918
Simon Gare wrote on 16 apr 2007 in
microsoft.publi c.inetserver.as p.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='jscri pt' runat='server'>

function addDecPoint(x){
var s = (x<0)?'-':'';
x = Math.abs(x);
x=(x<100)?((x+1 000)+'').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("i d")
waiting = Request.Form("w aiting")
carPark = Request.Form("c arPark")

driverNo = Request.Form("d riverNo")
sId = Request.Form("s Id")

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.CreateOb ject("ADODB.Con nection")
conn.Open g_connectionStr ing

' Updating booking_form...

sql = "UPDATE booking_form SET waiting_in_minu tes='" & waiting & "',
car_park='" & carPark & "', time_cleared=GE TDATE(), allocated='COMP LETED'
WHERE ID=" & id

conn.Execute(sq l)
<script language='jscri pt' runat='server'>

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

</script>

Apr 16 '07 #3
Simon Gare wrote on 16 apr 2007 in
microsoft.publi c.inetserver.as p.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='jscri pt' runat='server'>

function addDecPoint(x){
var s = (x<0)?'-':'';
x = Math.abs(x);
x=(x<100)?((x+1 000)+'').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("i d")
waiting = Request.Form("w aiting")
carPark = Request.Form("c arPark")

driverNo = Request.Form("d riverNo")
sId = Request.Form("s Id")

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.CreateOb ject("ADODB.Con nection")
conn.Open g_connectionStr ing

' Updating booking_form...

sql = "UPDATE booking_form SET waiting_in_minu tes='" & waiting &
"',
car_park='" & carPark & "', time_cleared=GE TDATE(),
allocated='COMP LETED' WHERE ID=" & id

conn.Execute(sq l)
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(cen tsValueFromData base)
%>

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
8782
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 BY clause is invalid in views, inline functions, derived tables, and subqueries, unless TOP is also specified Here is my sql statement:
0
1730
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 expression to {0:c} ********* Have the following code in the DataGrid1_UpdateCommand event handler string key = DataGrid1.DataKeys.ToString();
1
3803
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 from another table... Easy as pie in .mdb. Of course In the stored procedure it barks at me and tells me that an update query can only have one table.. ouch that hurts... I'm currently reading on the subject but this group has been very helpful...
2
2871
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 Wizard with generatedDataset and generated Select, Update, Insert and Deletecommands, controls bound to DataSet using the AdvancedDatabinding properties) Issue: Do I have to set parameters before I issue theDataSet.Update(Dataset, )? Again, my...
5
4561
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 dollar sign, the comma, and the decimal are included (i.e. $44,644.48) Managed to update the price column of the datagrid back to the database, as long as, the user doesn't delete the dollar sign (in the 0 position).
1
1819
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 when I have a 'datetime' column in the table. I tested this with a very simple sample table. As long as there is no datetime column either in the table or on the form, all are peachy. Here is the code, in case somebody can figure it out. I...
4
7239
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 - "Modified" of type DateTime - is hidden since it should not be edited by a user. The system handles the update for this column. So, I have hidden (Visible=false) this column on the grid. In order to access the value in this field, I have created a...
3
2259
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 bring the timing down to 5 minutes or less. Environment: DB2 V8.1 FP 12 / AIX 5.3 Both are non-partitioned tables..residing on a logically partitioned database
0
8440
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8355
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8638
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7381
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4193
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2769
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2006
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1769
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.