SQL Server next payment number function

Use NPNO to calculate the next payment number for loan with regularly scheduled periodic payments.

Syntax

SELECT [wctFinancial].[wct].[NPNO] (

<@SettDate,datetime,>

,<@FirstPayDate,datetime,>

,<@Pmtpyr,int,>

,<@NumPmts,int,>)

Arguments

@SettDate

the date from which you want to calculate the next payment number. The next payment number is always associated with the minimum payment date greater than @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

·@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 NPD will not return a number greater than the @NumPmts.

·If @SettDate < @FirstPayDate then 1 is returned

Example

Calculate the next 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 wct.NPNO(

'11/01/2010'--@SettDate

,'09/15/2010'--@FirstPayDate

,12 --@Pmtpyr

,NULL--@NumPmts

)as NPNO

This produces the following result.

NPNO

----------------------

3

(1 row(s) affected)

Calculate the next 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 wct.NPNO(

'10/29/2010'--@SettDate

,'7/29/2009'--@FirstPayDate

,26 --@Pmtpyr

,NULL--@NumPmts

)as NPNO

This produces the following result.

NPNO

----------------------

34

(1 row(s) affected)

Calculate the next payment number on 10/29/2010 for a loan that commenced on 2/28/2009, paying interest every semi-monthly starting on 3/15/2009.

SELECT wct.NPNO(

'10/29/2010'--@SettDate

,'3/15/2009'--@FirstPayDate

,24 --@Pmtpyr

,NULL--@NumPmts

)as NPNO

This produces the following result.

NPNO

----------------------

41

(1 row(s) affected)

Calculate the next payment number on 12/6/2010 for a loan that commenced on 12/06/2010, paying interest monthly on the 15th of the month, starting 12/15/2010.