Subject | Re: {Disarmed} Re: [firebird-support] How do I determine a percentage of a dollar amount? |
---|---|
Author | SoftTech |
Post date | 2011-07-11T17:04:48Z |
Thank you Marcin for the reply.
Input variable V_SETTLEMENT_PERCENTAGE is defined as a SmallInt
These are the values for items used below:
ITEM_TYPE_CODE = 'P'
ITEM_BAL_DUE = 150
V_SETTLEMENT_PERCENTAGE = 50 (Can be any value be 10 and 100)
Then in my code I try this:
IF (ITEM_TYPE_CODE = 'P') THEN
WRITE_OFF_AMOUNT = ITEM_BAL_DUE * (:V_SETTLEMENT_PERCENTAGE / 100);
It returns 0
So then I declared this variable:
DECLARE VARIABLE nSettlementPercentage Numeric(4,2);
and tried this:
nSettlementPercentage = (:V_SETTLEMENT_PERCENTAGE / 100);
which returns 0 (Should be 0.50)
and this
nSettlementPercentage = (50 / 100);
which returns 0 (Should be 0.50)
and finally this:
nSettlementPercentage = 0.50;
which returned 0.50
Which would then work with this code:
IF (ITEM_TYPE_CODE = 'P') THEN
WRITE_OFF_AMOUNT = ITEM_BAL_DUE * nSettlementPercentage;
So my question is why is 0 being returned for a variable input value?
Any futher help appreciated.
Thanks,
Mike
Input variable V_SETTLEMENT_PERCENTAGE is defined as a SmallInt
These are the values for items used below:
ITEM_TYPE_CODE = 'P'
ITEM_BAL_DUE = 150
V_SETTLEMENT_PERCENTAGE = 50 (Can be any value be 10 and 100)
Then in my code I try this:
IF (ITEM_TYPE_CODE = 'P') THEN
WRITE_OFF_AMOUNT = ITEM_BAL_DUE * (:V_SETTLEMENT_PERCENTAGE / 100);
It returns 0
So then I declared this variable:
DECLARE VARIABLE nSettlementPercentage Numeric(4,2);
and tried this:
nSettlementPercentage = (:V_SETTLEMENT_PERCENTAGE / 100);
which returns 0 (Should be 0.50)
and this
nSettlementPercentage = (50 / 100);
which returns 0 (Should be 0.50)
and finally this:
nSettlementPercentage = 0.50;
which returned 0.50
Which would then work with this code:
IF (ITEM_TYPE_CODE = 'P') THEN
WRITE_OFF_AMOUNT = ITEM_BAL_DUE * nSettlementPercentage;
So my question is why is 0 being returned for a variable input value?
Any futher help appreciated.
Thanks,
Mike
----- Original Message -----
From: Marcin Bury
To: firebird-support@yahoogroups.com
Sent: Monday, July 11, 2011 11:01 AM
Subject: {Disarmed} Re: [firebird-support] How do I determine a percentage of a dollar amount?
Hello Mike
As far as I remember 60% is 0.6 so when you supply percentage as
parameter you should perform following calculation:
result = (amount_in_dollars) * (a_percentage) / 100
This should do the trick ;-)
Marcin
W dniu 11.07.2011 17:56, SoftTech pisze:
> Greetings All,
>
> Firebird 1.53
>
> Inside a stored procedure I need to determine the percentage of a dollar
> amount.
>
> Is there a function or code that will return say 60% of $150.00?
>
> Thanks to anyone that replies,
>
> Mike
>
>
>
> ------------------------------------
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://www.firebirdsql.org and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Yahoo! Groups Links
>
>
>
>
--
MailScanner Virus/Spam/Malware: PASS (GZ)
[Non-text portions of this message have been removed]