Hi, William, and thanks for the reply...

1.  dB column is defined as "decimal(10,2)NOT NULL"

2.  You might know quicker than I based the query insert code:

        update accounts
        set balance = <cfqueryparam cfsqltype="cf_sql_decimal"
value="#LSParseNumber(current_balance)#">
        where account_id = '#get_accounts.account_id#'

    Would this cause the "balance" column variable to come
    an integer?  I figured setting the cfsqltype to cf_sql_decimal
    would preserve two decimal places...

But here's the code that processes the various numbers involved:

-------------------------------------------------------------------------------

(The code below adds up the current balances in the expense accounts as 
"total_expense")

select sum(monthly_expense) as total_expense from accounts where account_type = 
'Expense'

--------------------------------------------------------------------------------

(This code takes a current account balance (stored as decimal 10, 2) and
calculates what percentage of "total_expense" is in the budget expense 
accounts.)
        
<cfset new_amount = get_accounts.balance
+ ((get_accounts.monthly_expense/get_total_expense.total_expense)
*#LSParseCurrency(form.trans_amount)#)>
                                
--------------------------------------------------------------------------------

(This code take the current balance in an expense account and adds the 
appropriate
percentage of the deposit to it)

<cfset total_deposit = #decimalformat(total_deposit + new_amount)#>

-----------------------------------------------------------------------------------

I've tried variations on this theme for a couple of days now, trying to hit the 
right
type of calculations, but I still haven't found where I'm going wrong.

Rick 


> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Thursday, November 01, 2007 12:58 PM
> To: CF-Talk
> Subject: Re: How to break down a number into percentages
> 
> couple of questions.
> 
> 1.  Your dB column, is it set to 'decimal 2' or is it set to 'decimal
> [#],2'
> 2.  When you add up the numbers from the dB, are you converting them
> to integers before adding them up?
> 3.  If the above are not the issue, can you please post the code so we
> can find the issue?
> 
> William
> 
> -
> -Anybody have any clues how this should be approached?
> -
> -If the description above is not sufficient, I can give some concrete
> -examples with actual numbers, but I figured someone had tackled
> -something like this before.
> -
> -Thanks,
> -
> -Rick
> -
> -PS - I am on CF 8 now, so every solution is in play!  :o)
> -




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Download the latest ColdFusion 8 utilities including Report Builder,
plug-ins for Eclipse and Dreamweaver updates.
http;//www.adobe.com/cfusion/entitlement/index.cfm?e=labs%5adobecf8%5Fbeta

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:292498
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