Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12171

SQL Server not producing same result as Excel

$
0
0

I have the following PMT function:

create function dbo.PMT(    @rate float,    @periods numeric(20,7),    @principal numeric(20,2))returns numeric (38,9)asbegin    declare @pmt numeric (38,9)    declare @WK_periods float,        @WK_principal float,        @wk_One float,        @WK_power float    select  @WK_periods = @periods,        @WK_principal = @principal,        @WK_One = 1    select  @pmt =        round(        ( @WK_principal * (@rate*power(@WK_One+@rate,@WK_periods)))        / (power(@WK_One+@rate,@WK_periods)-@WK_One)        ,9)    return @pmtendgo

and called with the following parameters:

SELECT dbo.PMT(0.006313333, 251.1762480, 1814647.77)

the result is 14425.46 while excel is producing 14334.96. Though, I noticed that excel user added 2 extra parameters, which make it different from SQL result. So, in excel, the PMT function is called as =PMT(0.006313333, 251.1762480, 1814647.77, 0, 1). I could add those 2 parameters but don't know what to do with them in the function as I don't understand their implementation.

I need help to make SQL server produce same result as Excel.


Viewing all articles
Browse latest Browse all 12171

Trending Articles