472,373 Members | 2,070 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,373 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 2874
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: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

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.