April 27, 2005 at 12:28 pm
I am trying to do this calculation in a stored procedure but I just get zeros until I get to 12 if @NumPayments = 12.
(num.number + 1)/@NumPayments
I am sure this is because it is rounding the result and is not showing the decimal value. How do I change it so it places the decimal value in the table?
April 27, 2005 at 12:37 pm
(num.number + 1.0)/@NumPayments
Or declare @NumPayments as decimal if it's possible... but I'd got with + 1.0
April 28, 2005 at 11:26 am
You might want to post a little of your code. If you really have some type of 'IF' clause like that shown below it won't divide until you @NumPayments = 12; not 11 or 10 or any other number.
if @NumPayments = 12
(num.number + 1)/@NumPayments
April 28, 2005 at 11:35 am
anything between 0 and 11 (int) divided by 12 (int) = 0, then 1 untill you get to 24. That's why I changed the 1 to 1.0 (decimal) / (int) = (decimal)
April 28, 2005 at 12:08 pm
I believe you missed the point I was trying to make. Your (num.number + 1)/@NumPayments) statement only fires when @NumPayment = 12. That's why I suggested posting the code; so we could look at the unambiguous code rather than a statement of content. Since I only inferred from your first statement that the code contained an IF statement, my earlier post could be based on a faulty assumption.
April 28, 2005 at 12:18 pm
we're both making assumptions and without the code there's no point in continuing this discussion.. I'll wait for his answer before drawing any final conclusion.
April 28, 2005 at 1:34 pm
changing the 1 to 1.0 did the trick - thank you
April 28, 2005 at 1:36 pm
NP.
April 29, 2005 at 1:06 am
NP
What does this stand for?
Curtis,
I believe this only to be a small part of your proc. What are you dealing with? By any chance, are you dealing a time value of money problem? I might be wrong, but to me this looks like you're doing some compounding here. If so, here's what I use for monthly compounding (@NumPayments = 12 in your case)
DECLARE @pv FLOAT
DECLARE @i FLOAT
DECLARE @m FLOAT
DECLARE @n FLOAT
SELECT
@pv=1000000, @i=0.06, @m=12, @n=1
SELECT
@pv*POWER(1+@i/@m,@m*@n)
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
April 29, 2005 at 6:30 am
NP = No problems
HTH = Happy to help
April 29, 2005 at 6:45 am
Thanks!
I should have flipped to page 3 here http://www.acronymfinder.com/af-query.asp?acronym=np&String=exact&page=3
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
April 29, 2005 at 9:34 am
Frank
I am doing compounding. My procedure is similar to the way you do it.
Thanks for the input!
May 2, 2005 at 12:54 am
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
Viewing 13 posts - 1 through 12 (of 12 total)
You must be logged in to reply to this topic. Login to reply