Login     Register

        Contact Us     Search

XLeratorDB/financial Documentation

SQL Server previous payment number function


PPNO
 
Updated: 06 December 2010

Use PPNO to calculate the previous payment number for loan with regularly scheduled periodic payments.
Syntax
SELECT [wctFinancial].[wct].[PPNO] (
  <@SettDate, datetime,>
 ,<@FirstPayDate, datetime,>
 ,<@pmtpyr, int,>
 ,<@NumPmts, int,>)
Arguments
@SettDate
the date from which you want to calculate the previous payment number. The previous payment number is always associated with the maximum payment date less than or equal to @SettDate. @SettDate is an expression of type datetime or of a type that can be implicitly converted to datetime.
@FirstPayDate
the date that the first payment is due. @FirstPayDate is an expression of type datetime or of a type that can be implicitly converted to datetime.
@Pmtpyr
the number of loan payments made in a year. @NumPmts is an expression of type int or of a type that can be implicitly converted to int.
@NumPmts
the total number of payments to be recorded over the life of the loan. @NumPmts is an expression of type int or of a type that can be implicitly converted to int.
Return Type
float
Remarks
·         If@SettDate < @FirstPayDate, NULL is returned
·         @Pmtpyr must be between 1 and 365
·         If @Pmtpyr = 13, then payments are calculated every 28 days from @FirstPayDate.
·         If @Pmtpyr = 26, then payments are calculated every 14 days from @FirstPayDate.
·         If @Pmtpyr = 52, then payments are calculated every 7 days from @FirstPayDate.
·         If @Pmtpyr = 1, then payments are calculated every 1 year from @FirstPayDate.
·         If @Pmtpyr = 2, then payments are calculated every 6 months from @FirstPayDate.
·         If @Pmtpyr = 3, then payments are calculated every 4 months from @FirstPayDate.
·         If @Pmtpyr = 4, then payments are calculated every 3 months from @FirstPayDate.
·         If @Pmtpyr = 6, then payments are calculated every 2 months from @FirstPayDate.
·         If @Pmtpyr = 12, then payments are calculated every 1 month from @FirstPayDate.
·         If @Pmtpyr = 24, then payments are calculated every semi-monthly from @FirstPayDate. If the @FirstPayDate is the 15th of the month, payments are on the 15th and the last day of the month. If the @FirstPayDate is the last day of the month, then payment dates are on the last day of the month and the 15th day of the month.
·         If @NumPmts IS NOT NULL, then PPD will not return a payment number greater than the number of payments.
Example
Calculate the previous payment number on 11/1/2010 for a loan that commenced on 8/31/2008, paying interest monthly on the 15th of the month, starting 9/15/2008.
SELECT dbo.PPNO(
       '11/01/2010'     --@SettDate
      ,'09/15/2010'     --@FirstPayDate
      ,12               --@Pmtpyr
      ,NULL             --@NumPmts
      ) as PPNO
This produces the following result.
PPNO
----------------------
2
 
(1 row(s) affected)

Calculate the previous payment number on 10/29/2010 for a loan that commenced on 7/15/2009, paying interest every two weeks starting on 7/29/2009.
SELECT dbo.PPNO(
       '10/29/2010'     --@SettDate
      ,'7/29/2009'      --@FirstPayDate
      ,26               --@Pmtpyr
      ,NULL       --@NumPmts
      ) as PPNO
This produces the following result.
PPNO
----------------------
33
 
(1 row(s) affected)

Calculate the next payment number on 10/29/2010 for a loan that commenced on 2/28/2009, paying interest semi-monthly starting on 3/15/2009.
SELECT dbo.PPNO(
      '10/29/2010'      --@SettDate
      ,'3/15/2009'      --@FirstPayDate
      ,24               --@Pmtpyr
      ,NULL             --@NumPmts
      ) as PPNO
This produces the following result.
PPNO
----------------------
40
 
(1 row(s) affected)
 
Calculate the previous payment number on 12/6/2010 for a loan that commenced on 12/6/2008, paying interest monthly on the 15th of the month, starting 12/15/2010.
SELECT wct.PPNO(
       '12/6/2010'      --@SettDate
      ,'12/15/2010'     --@FirstPayDate
      ,12               --@Pmtpyr
      ,NULL             --@NumPmts
      ) as PPNO
This produces the following result.
                  PPNO
----------------------
                  NULL
 

(1 row(s) affected)



Copyright 2008-2017 Westclintech LLC         Privacy Policy        Terms of Service