locked
PMT Calculation with T-SQL RRS feed

  • คำถาม

  • Hi there,

    I am having this issue where I have to calculate the PMT of a lon with T-SQL script. the Excel formula to calculate such a thing is; PMT(rate,nper,pv,fv,type)

    I'm trying to get the same results with a SQL script but I'm not having any luck. this is what I'm doing here;


    declare @pv money
    declare @fv money
    declare @nper int
    declare @APR float
    declare @months int
    declare @pmt money

    set @pv=49581.89;
    set @fv=0.0;
    set @nper=182;
    set @months=12;
    set @APR=.058;

    select (@PV-@FV)/@NPER --a.k.a the Principal payment
    + (@PV+@FV-(@PV-@FV)/@NPER)/2*(@APR/@months)  -interest_payment

     


    the results with this script is; $391.59

    when I run the same numbers with the PMT formula in Excel I get; $410.21 which the correct one.

    Can somebody tell me what Am I missing in the SQL Script?

    Thanks very much for your help in advance.

    Manny

    10 ตุลาคม 2552 17:54

คำตอบ

ตอบทั้งหมด