Considering it's an inventory system... I wouldn’t type the numbers to a
string like that. I'd leave them numerical data types since the chance of
another application using the same data is pretty high.

Jenny's solution is the right one [var * -1]

Or even [var - (var * 2)]

But what if they enter a negative number? Just to be safe... Negative x
negative = positive ;-)

Make sure to get the absolute value of the number before multiplying it by a
negative number

[abs(var) * -1]

-or-

[abs(var) - (abs(var) * 2)]

..:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com

 

 


-----Original Message-----
From: Richard Dillman [mailto:[EMAIL PROTECTED] 
Sent: Sunday, September 17, 2006 12:56 PM
To: CF-Talk
Subject: Re: Negative and positive

cfquery name="name" datasource="#dsn#">
   INSERT INTO Stock
   VALUES (#Form.Item_ID#, '-#Form.ammount#',)
</cfquery>

On 9/17/06, Chad Gray <[EMAIL PROTECTED]> wrote:
>
> I am working on an inventory system where people put in a number of items
> that are being taken out of inventory and put into inventory.
>
> The users are entering positive numbers.
>
> I need to store the number as a negative in the database if inventory is
> being removed.
>
> How do I convert the number they enter to a negative before I insert it
> into the database?
>
> I am sure it is something simple I am just a little burnt out.
> Thanks!
>
>
> 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:253381
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to