Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding two Numbers in a CFSET 2

Status
Not open for further replies.

wilcoHead

Programmer
Feb 2, 2005
85
0
0
Hello;

I have to fields (currency Format)in access.

I would like to do this in a CFSET tag.

Query = GetDealer

#Accrued# - #Used# = Net

So it would look like this:

10 - 5 = 5


Thanks for your input;
WilcoHEAD
 
<cfset "#Accrued# - #Used# = #DollarFormat(Accrued -Used)#">

Is what I think you are going for. Of course NumberFormat or Decimal Format would work as well.
 
Cool;

Then I would Just do a <CFoutput> to
generate the sum?



Thanks for your input;
WilcoHEAD
 
If you <cfset variableSomething = "#Accrued# - #Used# = #DollarFormat(Accrued -Used)#">

Then you can do <cfoutput>#variableSomething#</cfouput> and you will get

10 - 5 = $5.00
 
Thanks! - That works.

Thanks for your input;
WilcoHEAD
 
You should also look into manipulating the data during the query

In mysql you can do

select intField1 + intField2 AS totalintFields
from table
etc...

Access does it the same or similar...

 
I will look at that too. I am using access.

Thanks for your input;
WilcoHEAD
 
The CFSET Somewhat works but is generating 3 sets of numbers rather than one.

-----------------------------------------------------
Here is the CFSET:
-----------------------------------------------------
<cfset TotalNet = "#GetDealer.Accrued# - #GetDealer.Used# = #DollarFormat(GetDealer.Accrued -GetDealer.Used)#">
-----------------------------------------------------
Here is The Output:
-----------------------------------------------------
<CFOUTPUT query="GetDealer">
<TD>#Distributor#</TD>
<TD width="50"><INPUT name="Accrued" type="text" style="border:1px ##CCCCCC solid" value="#Accrued#"></TD>
<TD width="50"><INPUT name="Used" type="text" style="border:1px ##CCCCCC solid" value="#Used#"></TD>
<TD width="50"><CFOUTPUT>#TotalNet#</CFOUTPUT></TD>
<CFIF GetDealer.Distributor EQ "*Anesthesia Services & Products"><TD width="100"><INPUT name="RebateAccrual" type="text" style="border:1px ##CCCCCC solid" value="#RebateAccrual#"></TD><CFELSE></CFIF>
<TD align="center"><INPUT name="Add" type="submit" value="Add" style="border:1px ##CCCCCC solid"></TD>
</CFOUTPUT>
-------------------------------------------------------
This is what I get: (showing just Net Column)
-------------------------------------------------------
NET
6000.0000 - 2650.0000 = $3,350.00
--------------------------------------------------------
Notice how it generates all 3 numbers? I just want it to show the "$3,350.00"
---------------------------------------------------------


Thanks for your input;
WilcoHEAD
 
Nevermind, I got it

Thanks for your input;
WilcoHEAD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top