SQL Server PDURATION Function
Updated 2024-02-28 20:29:28.027000
Description
Use the scalar function PDURATION to calculate the number of periods required by an investment to reach a specified value. The formula is:
PDURATION=\frac{\ln{fv}-\ln{pv}}{\ln{\left(rate+1\right)}
Where
| column 1 | column 2 | column 3 |
|---|---|---|
| fv | = | the future value of the investment |
| pv | = | the present value of the investment |
| rate | = | the periodic interest rate. |
Syntax
SELECT [westclintech].[wct].[PDURATION] (
<@Rate, float,>
,<@PV, float,>
,<@FV, float,>)
Arguments
@Rate
Periodic interest rate. @Rate must be of type float or of a type that implicitly converts to float.
@PV
Present value of the investment. @PV must be of type float or of a type that implicitly converts to float.
@FV
Future value of the investment. @FV must of a type float or of a type that implicitly converts to float.
Return Type
float
Remarks
If @PV is NULL then @PV = 0.
If @PV = 0 then NULL is returned.
If @FV is NULL then @FV = 0.
If @FV = 0 then NULL is returned.
If @Rate is NULL then @Rate = 0.
If @Rate = 0 then NULL is returned.
If @Rate < -1 then NULL is returned.
Examples
SELECT wct.PDURATION( wct.PERIODRATE(.08, 1, 12) / 12, --@Rate
1000, --@PV
1259.712 --@FV
) as PDURATION;
This produces the following result.
| PDURATION |
|---|
| 36.0000000000002 |
See Also
RRI - Calculate an equivalent interest rate for the growth of an investment.
RATE - Rate of an annuity given number of periods, periodic payment, present value, and future value
NPER - number of periods in an annuity
PV - Present value of an annuity
ODDPV - Calculate the present value of an annuity with an odd first period
LRATE - annual interest rate for an annuity with an odd first period