Logo

SQL Server ODDFPMTSCHED Function

Updated 2023-10-06 21:42:47.807000

Description

Use the table-valued function ODDFPMTSCHED to generate an amortization schedule for an annuity where the first period is either longer or shorter than all the other periods.

Syntax

SELECT * FROM [wct].[ODDFPMTSCHED](
  <@Rate, float,>
 ,<@Nper, int,>
 ,<@PV, float,>
 ,<@FV, float,>
 ,<@FirstPeriod, float,>)

Arguments

@Rate

the periodic interest rate. @Rate is an expression of type float or of a type that can be implicitly converted to float.

@Nper

the number of annuity payments. @Nper is an expression of type int or of a type that can be implicitly converted to int.

@PV

the present value of the annuity. @PV is an expression of type float or of a type that can be implicitly converted to float.

@FV

the future value as at the end of the annuity. @FV is an expression of type float or of a type that can be implicitly converted to float.

@FirstPeriod

the length of the first period. @FirstPeriod is an expression of type float or of a type that can be implicitly converted to float.

Return Type

table

colNamecolDatatypecolDesc
num_pmtintPayment number
amt_prin_initfloat Initial principal amount; amt_prin_end from the previous row
amt_int_payfloat Interest portion of the periodic payment
amt_prin_payfloat Principal portion of the periodic payment
amt_prin_endfloatEnding principal amount; amt_prin_init – amt_prin_pay

Remarks

If @Rate <= -1 then no rows are returned.

If @Nper < 1 then no rows are returned.

If @FirstPeriod <= 0 then no rows are returned.

If @Nper is NULL then @Nper = 1.

If @Rate is NULL then @Rate = 0.

If @PV is NULL then @PV = 0.

If @FV is NULL then @FV = 0.

If @FirstPeriod is NULL then @FirstPeriod = 1.

amt_prin_pay for the final period includes @FV so that the amt_prin_end for the final period is zero.

ODDFPMTSCHED uses the same conventions for the sign of the inputs and the results as Excel and Google spreadsheets; generally @PV and @FV should have opposite signs and the periodic interest and principal payments will have the opposite sign of @PV.

Examples

Generate a payment schedule for an annuity assuming a periodic rate of 0.5%, with 36 periodic payments. The price of the annuity is 11,500 and there is no cash value at the end of the annuity. The first period is 1 and 5/6th longer than the other periods.

SELECT *
FROM wct.ODDFPMTSCHED(   .005,         --@Rate
                         36,           --@Nper
                         -11500,       --@PV
                         0,            --@FV
                         1 + 5 / 6e+00 --@FirstPeriod
                     );

This produces the following result.

num_pmtamt_prin_initamt_int_payamt_prin_payamt_prin_end
000011500
111500105.416666666668245.88607953489911254.1139204651
211254.113920465156.2705696023263295.03217659924110959.0817438659
310959.081743865954.795408719338296.5073374822310662.5744063836
410662.574406383653.3128720319278297.9898741696410364.584532214
510364.58453221451.8229226610788299.47982354048910065.1047086735
610065.104708673550.3255235433721300.9772226581959764.12748601531
79764.1274860153148.8206374300848302.4821087714839461.64537724382
89461.6453772438247.3082268862167303.9945193153519157.65085792847
99157.6508579284745.7882542896573305.514491911918852.13636601656
108852.1363660165644.2606818300924307.0420643714758545.09430164509
118545.0943016450942.7254715082222308.5772746933458236.51702695174
128236.5170269517441.1825851347699310.1201610667987926.39686588494
137926.3968658849439.6319843294318311.6707618721367614.72610401281
147614.7261040128138.0736305200658313.2291156815027301.49698833131
157301.4969883313136.5074849416674314.79526125996986.70172707141
166986.7017270714134.9335086353599316.3692375662086670.3324895052
176670.332489505233.3516624475337317.9510837540346352.38140575117
186352.3814057511731.7619070287606319.5408391728076032.84056657836
196032.8405665783630.164202832902321.1385433686665711.70202320969
205711.7020232096928.5585101160618322.7442360855065388.95778712419
215388.9577871241926.9447889356293324.3579572659385064.59982985825
225064.5998298582525.3229991492922325.9797470522754738.62008280597
234738.6200828059723.6931004140429327.6096457875254411.01043701845
244411.0104370184522.0550521850978329.247694016474081.76274300198
254081.7627430019820.4088137150197330.8939324865483750.86881051543
263750.8688105154318.7543440525824332.5484021489853418.32040836645
273418.3204083664517.0916020418299334.2111441597383084.10926420671
283084.1092642067115.4205463210515335.8821998805162748.22706432619
292748.2270643261913.7411353216371337.561610879932410.66545344626
302410.6654534462612.0533272672383339.2494189343292071.41603451193
312071.4160345119310.3570801725564340.9456660290111730.47036848292
321730.470368482928.65235184242761342.650394359141387.81997412378
331387.819974123786.93909987062329344.3636463309441043.45632779284
341043.456327792845.21728163897058346.085464562597697.370863230241
35697.3708632302413.48685431616252347.815891885405349.554971344836
36349.5549713448361.74777485673167349.5549713448360

In this example we generate a payment schedule for an annuity assuming a periodic rate of 0.5%, with 180 periodic payments. The price of the annuity is 250,000 and there is a 50,000 cash value at the end of the annuity. The first period is one-half as long as the other periods. We will return the last 24 rows.

SELECT *
FROM
(
    SELECT TOP 24
           *
    FROM wct.ODDFPMTSCHED(   .005,    --@Rate
                             180,     --@Nper
                             -250000, --@PV
                             50000,   --@FV
                             0.5      --@FirstPeriod
                         )
    ORDER BY num_pmt DESC
) n
ORDER BY 1 ASC;

This produces the following result.

num_pmtamt_prin_initamt_int_payamt_prin_payamt_prin_end
15787961.2505481276439.8062527406771492.6595375101886468.5910106174
15886468.5910106174432.342955053091500.1228351977684968.4681754197
15984968.4681754197424.8423408771531507.623449373783460.844726046
16083460.844726046417.3042236302471515.1615666206181945.6831594254
16181945.6831594254409.7284157971491522.737374453780422.9457849717
16280422.9457849717402.1147289248951530.3510613259678892.5947236457
16378892.5947236457394.4629736182591538.0028166325977354.5919070131
16477354.5919070131386.7729595351451545.6928307157175808.8990762974
16575808.8990762974379.0444953815211553.4212948693374255.4777814281
16674255.4777814281371.2773889071441561.1884013437172694.2893800844
16772694.2893800844363.4714469004871568.9943433503671125.295036734
16871125.295036734355.6264751837051576.8393150671569548.4557216669
16969548.4557216669347.7422786083671584.7235116424967963.7322100244
17067963.7322100244339.8186610501621592.6471292006966371.0850808237
17166371.0850808237331.8554254040981600.6103648467564770.4747159769
17264770.4747159769323.8523735799721608.6134166708863161.8612993061
17363161.8612993061315.8093064965621616.6564837542961545.2048155518
17461545.2048155518307.7260240777951624.7397661730659920.4650493787
17559920.4650493787299.6023252468771632.8634650039758287.6015843747
17658287.6015843747291.4380079219311641.0277823289256646.5738020458
17756646.5738020458283.2328690102481649.232921240654997.3408808052
17854997.3408808052274.9867044040551657.479085846853339.8617949584
17953339.8617949584266.6993089748471665.76648127651674.0953136824
18051674.0953136824258.37047656844951674.09531368240

In this example we c alculate the weekly payment for an automobile lease with a term of 3 years and an annual interest rate of 25%. The amount to be financed is 11,000 and the residual value at the end of the lease is 3,500. The first payment is due 2014-11-25 and we will return the first 52 payments.

SELECT TOP 53
       *
FROM wct.ODDFPMTSCHED(   .25 * 7 / 365e+00,                              
          --@Rate
                         156,                                            
                                   --@Nper
                         -11000,                                         --@PV
                         3500,                                           --@FV
                         DATEDIFF(d, '2014-11-13', '2014-11-25') / 7e+00 
                                   --@FirstPeriod
                     )
ORDER BY num_pmt ASC;

This produces the following result.

num_pmtamt_prin_initamt_int_payamt_prin_payamt_prin_end
000011000
11100090.4109589041082-4.9013015474429311004.9013015474
211004.901301547452.7632254183832.746431938285210972.1548696092
310972.154869609252.606221977578632.903435379086710939.2514342301
410939.251434230152.448465780556133.061191576109210906.190242654
510906.19024265452.289953218202833.219704138462510872.9705385155
610872.970538515552.130680664117833.378976692547410839.591561823
710839.59156182351.970644474492533.539012882172810806.0525489408
810806.052548940851.809840988074133.699816368591210772.3527325722
910772.352732572251.648266526029233.861390830636110738.4913417416
1010738.491341741651.485917391913134.023739964752210704.4676017768
1110704.467601776851.322789871533234.186867485132110670.2807342917
1210670.280734291751.158880232905234.350777123760110635.9299571679
1310635.929957167950.99418472614834.515472630517310601.4144845374
1410601.414484537450.828699583399734.680957773265610566.7335267641
1510566.733526764150.66242101873234.847236337933310531.8862904262
1610531.886290426250.495345228070735.014312128594610496.8719782976
1710496.871978297650.327468389096835.182188967568410461.68978933
1810461.6897893350.158786661172635.350870695492610426.3389186345
1910426.338918634549.989296185235735.520361171429610390.8185574631
2010390.818557463149.818993083726235.690664272939110355.1278931902
2110355.127893190249.647873460499835.861783896165410319.266109294
2210319.26610929449.475933400725936.033723955939410283.2323853381
2310283.232385338149.303168970803236.20648838586210247.0258969522
2410247.025896952249.129576218260936.380081138404410210.6458158138
2510210.645815813848.955151171711836.554506184953410174.0913096288
2610174.091309628848.779889840684636.729767515980710137.3615421129
2710137.361542112948.603788215609836.905869141055510100.4556729718
2810100.455672971848.426842267675137.082815088990210063.3728578828
2910063.372857882848.249047948752437.260609407912910026.1122484749
3010026.112248474948.070401191319537.43925616534589988.67299230956
319988.6729923095647.890897908334537.61875944833089951.05423286123
329951.0542328612347.710533993170537.79912336349489913.25510949773
339913.2551094977347.529305319510137.98035203715529875.27475746058
349875.2747574605847.347207741248938.16244961541639837.11230784516
359837.1123078451647.164237092410138.34542026425529798.7668875809
369798.766887580946.980389187031538.52926816963379760.23761941127
379760.2376194112746.795659819093138.71399753757219721.5236218737
389721.523621873746.610044762409538.89961259425589682.62400927944
399682.6240092794446.423539770518839.08611758614649643.5378916933
409643.537891693346.236140576610639.27351678005479604.26437491324
419604.2643749132446.047842893421239.46181446324419564.80256045
429564.8025604545.858642413118139.65101494354719525.15154550645
439525.1515455064545.668534807223339.84112254944199485.31042295701
449485.3104229570145.477515726505840.03214163015959445.27828132685
459445.2782813268545.285580800883640.22407655578179405.05420477107
469405.0542047710745.092725639312540.41693171735289364.63727305372
479364.6372730537244.898945829710140.61071152695519324.02656152676
489324.0265615267644.704236938826440.80542041783889283.22114110892
499283.2211411089244.508594512167341.00106284449799242.22007826442
509242.2200782644244.312014073871141.19764328279429201.02243498163
519201.0224349816344.114491126624741.39516623004069159.62726875159
529159.6272687515943.91602115155141.59363620511439118.03363254647

See Also

CUMODDFIPMT - Cumulative interest on the periodic annuity payments between a start period and an end period

CUMODDFPPMT - Cumulative principal on the periodic annuity payments between a start period and an end period

LPMTSCHED - Amortization schedule for a loan with constant periodic payemnts and an odd first period where interest is accrued using the US rule

ODDFIPMT - Interest portion of a periodic payment for an annuity with an odd first period

ODDFPPMT - Principal portion of a periodic payment for an annuity with an odd first period

ODDFPV - Present Value of an annuity with an odd first period

ODDFRATE - Rate of an annuity with an odd first period given number of periods, periodic payment, present value, and future value.

PMTSCHED - Calculate an amortization schedule for a loan with no odd periods.