Solved

* HILAIRE * - NPER Excel Function in MSSQL

Posted on 2004-08-04
4
941 Views
Last Modified: 2012-08-14
Hi All

I was searching through EE and viewed the question posted by ktrimmer: Payment function in MSSQL asked by ktrimmer on 11/26/2003 04:36AM PST  - Q_20809063.html

The solution was very informative and was of extreme assistance to me.

I am now looking for a function the equivalent of the excel NPER Function.
The following parameters are known.

Capital Amount - R 5000
Interest Rate - 20.3% .
Payment Amount - R 500 per month.

I want a function that can give me the number of months (taking into account interest) that a person will have to pay R500 for in order to settle a debt.

The excel funtion of NPER needs to be applied in MSSQL.
EG) =NPER(B5/12,B6,-B3)

B5 = 20.3%    B6 = 500, B3 = 5000

Hilaire .. your solution in previously asked question as mentioned above calculates rate as well as payment amount.  Is there a formulae/function in sql that will calculate No of Periods

Your assistance in this regard will be greatly appreciated

Thanking You
Regards
TAZI
0
Comment
Question by:TAZI
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 26

Expert Comment

by:Hilaire
ID: 11728091
Hi TAZI,

>>Is there a formulae/function in sql that will calculate No of Periods<<
No, you'll have to make your own

I tried to come up with my own version, based on an oarticle at this URL
http://www.duncanwil.co.uk/nper.html

I'm not a finance specialist, and I haven't found a correct algorithm for the moment

That would require more time than I have for the moment.
I'll let you know as soon as I find something better.

Hopefully other experts will join.

Cheers

Hilaire




0
 
LVL 26

Accepted Solution

by:
Hilaire earned 75 total points
ID: 11728356
Finally found something ...

I used formulas from MS : reference http://support.microsoft.com/?kbid=214005

create function NPER(@rate float, @payment float,@capital float)
returns float
as
begin
return log10(@payment/(@payment+@capital*@rate))/log10(1+@rate)
end
go

select dbo.NPER(.203/12, 500, -5000)  ---> returns 11.047592792208778

Hilaire
0
 
LVL 26

Expert Comment

by:Hilaire
ID: 11736415
Hi TAZI,

did you try my code above ?
0
 
LVL 1

Author Comment

by:TAZI
ID: 11760237
Hi

Yes, I tried your code and it works wonderfully.

Thanks a million
Sorry, I didn't get a chance to accept your question on Friday.  

Many Thanks
Regards
TAZI
0

Featured Post

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question