Logo

SQL Server ODDFSCHED Function

Updated 2023-10-06 22:31:05.990000

Description

Use the table-valued function ODDFSCHED to generate an annuity-like payment schedule where the first period is a different length of the time than all subsequent periods and those subsequent periods are assumed to be of equal length. Principal amortization, however, assumes all periods (including the first one) are of equal length. This results in a schedule where the cash flow for the first period is different than the cash flow for all subsequent periods.

To generate a payment schedule where the first period is of a different length but the payments are the same for all periods, use the ODDFPMTSCHED function.

Syntax

SELECT * FROM [westclintech].[wct].[ODDFSCHED](
  <@Rate, float,>
 ,<@Nper, int,>
 ,<@PV, float,>
 ,<@FV, float,>
 ,<@FirstPeriod, float,>
 ,<@IntRule, nvarchar(4000),>)

Arguments

@Rate

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

@Nper

the number of periods (repayments). @Nper is of type int or of a type that can be implicitly converted to int.

@PV

the present value or principal amount. @PV is of type float or of a type that can be implicitly converted to float.

@FV

the future value; the ending balance in the amortization schedule. @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 expressed in periods. @FirstPeriod is an expression of type float or of a type that can be implicitly converted to float.

@IntRule

use 'U' to calculate the first period interest using the US rule and 'A' to calculate first period interest using the Actuarial rule.

Return Type

table

colNamecolDatatypecolDesc
num_pmtintThe number of the payment from 0 to @Nper.
amt_prin_initfloatthe amt_prin_end from the previous row.
amt_pmtfloatamt_prin_pay + amt_int_pay.
amt_int_payfloatWhen num_pmt > 1 then PMT(@Rate,@Nper,@PV,@FV) - amt_prin_pay. When num_pmt = 1, if @IntRule = 'U' then amt_prin_init * @Rate * @FirstPeriod else amt_prin_init * (POWER(1+@Rate, @FirstPeriod) – 1).
amt_prin_payfloatamt_prin_init – amt_prin_end.
amt_prin_endfloat PV(@Rate,@Nper - num_pmt,PMT(@Rate,@Nper,@PV,@FV),@FV)

Remarks

@Rate must be greater than -1.

@Nper must be greater than zero.

@FirstPeriod must be greater than zero.

@IntRule must be either 'U' or 'A'.

Examples

Example #1

A loan for 11,500 to be amortized over 36 periods at a periodic interest rate of 0.5%. The first period is half as long as a regular period. Interest is accrued using the US method.

SELECT *
FROM wct.ODDFSCHED(   0.005,  --@Rate
                      36,     --@Nper
                      -11500, --@PV
                      0,      --@FV
                      0.5,    --@FirstPeriod
                      'U'     --@IntRule
                  );

This produces the following result.

num_pmtamt_prin_initamt_pmtamt_int_payamt_prin_payamt_prin_end
0000011500
111500321.1022806928828.75292.3522806928811207.6477193071
211207.6477193071349.85228069289156.038238596539293.81404209635210913.8336772108
310913.8336772108349.85228069289154.5691683860609295.2831123068310618.5505649039
410618.5505649039349.85228069289153.0927528245288296.75952786836210321.7910370356
510321.7910370356349.85228069289151.6089551851859298.24332550770510023.5477115279
610023.5477115279349.85228069289150.1177385576452299.7345421352469723.81316939263
79723.81316939263349.85228069289148.6190658469699301.2332148459219422.57995454671
89422.57995454671349.85228069289147.1128997727323302.7393809201599119.84057362655
99119.84057362655349.85228069289145.5992028681471304.2530778247448815.5874958018
108815.5874958018349.85228069289144.0779374790185305.7743432138728509.81315258793
118509.81315258793349.85228069289142.5490657629366307.3032149299548202.50993765798
128202.50993765798349.85228069289141.0125496883006308.839731004597893.67020665339
137893.67020665339349.85228069289139.4683510332738310.3839296596177583.28627699377
147583.28627699377349.85228069289137.916431384971311.935849307927271.35042768585
157271.35042768585349.85228069289136.3567521384397313.4955285544516957.8548991314
166957.8548991314349.85228069289134.7892744956602315.0630061972316642.79189293417
176642.79189293417349.85228069289133.2139594646782316.6383212282136326.15357170596
186326.15357170596349.85228069289131.6307678585358318.2215128343556007.9320588716
196007.9320588716349.85228069289130.0396602943669319.8126203985245688.11943847308
205688.11943847308349.85228069289128.4405971923802321.4116835005115366.70775497257
215366.70775497257349.85228069289126.8335387748697323.0187419180215043.68901305454
225043.68901305454349.85228069289125.2184450652744324.6338356276164719.05517742693
234719.05517742693349.85228069289123.5952758871476326.2570048057434392.79817262118
244392.79817262118349.85228069289121.9639908631106327.888289829784064.9098827914
254064.9098827914349.85228069289120.3245494139668329.5277312789243735.38215151248
263735.38215151248349.85228069289118.6769107575678331.1753699353233404.20678157716
273404.20678157716349.85228069289117.0210339078835332.8312467850073071.37553479215
283071.37553479215349.85228069289115.3568776739784334.4954030189122736.88013177324
292736.88013177324349.85228069289113.6844006588721336.1678800340192400.71225173922
302400.71225173922349.85228069289112.0035612587039337.8487194341872062.86353230503
312062.86353230503349.85228069289110.3143176615214339.5379630313691723.32556927366
321723.32556927366349.8522806928918.61662784638128341.235652846511382.08991642715
331382.08991642715349.8522806928916.91044958213996342.9418311107511039.1480853164
341039.1480853164349.8522806928915.19574042658843344.656540266302694.4915450501
35694.4915450501349.8522806928913.4724577252619346.379822967629348.111722082471
36348.111722082471349.8522806928911.74055861041978348.1117220824710

Example #2

A loan for 36000 to be amortized over 60 period at a periodic interest rate of 1.5%. The first period is 2/3 the length of a regular period and interest is accrued using the actuarial method.

SELECT *
FROM wct.ODDFSCHED(   0.015,  --@Rate
                      60,     --@Nper
                      -36000, --@PV
                      0,      --@FV
                      0.5,    --@FirstPeriod
                      'A'     --@IntRule
                  );

This produces the following result.

num_pmtamt_prin_initamt_pmtamt_int_payamt_prin_payamt_prin_end
0000036000
136000643.158410673721268.995023297793374.16338737592735625.8366126241
235625.8366126241914.163387375931534.387549189359379.77583818657135246.0607744375
335246.0607744375914.163387375931528.690911616573385.47247575935834860.5882986781
434860.5882986781914.163387375931522.908824480171391.2545628957634469.3337357824
534469.3337357824914.163387375931517.040006036735397.12338133919534072.2103544432
634072.2103544432914.163387375931511.083155316646403.08023205928533669.1301223839
733669.1301223839914.163387375931505.036951835758409.12643554017333260.0036868437
833260.0036868437914.163387375931498.90005530266415.26333207327132844.7403547705
932844.7403547705914.163387375931492.671105321566421.49228205436532423.2480727161
1032423.2480727161914.163387375931486.348721090751427.8146662851831995.4334064309
1131995.4334064309914.163387375931479.93150109646434.23188627947131561.2015201514
1231561.2015201514914.163387375931473.418022802274440.74536457365731120.4561555778
1331120.4561555778914.163387375931466.806842333666447.35654504226530673.0996105355
1430673.0996105355914.163387375931460.096494158042454.06689321788930219.0327173176
1530219.0327173176914.163387375931453.285490759761460.8778966161729758.1548207015
1629758.1548207015914.163387375931446.37232231053467.79106506540129290.3637556361
1729290.3637556361914.163387375931439.355456334542474.80793104138928815.5558245947
1828815.5558245947914.163387375931432.233337368925481.93005000700628333.6257745877
1928333.6257745877914.163387375931425.004386618817489.15900075711427844.4667738306
2027844.4667738306914.163387375931417.667001607464496.49638576846727347.9703880621
2127347.9703880621914.163387375931410.219555820931503.94383155526844.0265565071
2226844.0265565071914.163387375931402.660398347616511.50298902831526332.5235674788
2326332.5235674788914.163387375931394.987853512179519.17553386375225813.348033615
2425813.348033615914.163387375931387.20022050423526.96316687170125286.3848667433
2525286.3848667433914.163387375931379.295773001151534.8676143747824751.5172523685
2624751.5172523685914.163387375931371.272758785533542.89062859039824208.6266237781
2724208.6266237781914.163387375931363.129399356683551.03398801924823657.5926357589
2823657.5926357589914.163387375931354.863889536383559.29949783954723098.2931379193
2923098.2931379193914.163387375931346.474397068788567.68899030714222530.6041476122
3022530.6041476122914.163387375931337.959062214187576.20432516174321954.3998224505
3121954.3998224505914.163387375931329.315997336762584.84739003916921369.5524324113
3221369.5524324113914.163387375931320.543286486172593.62010088975920775.9323315215
3320775.9323315215914.163387375931311.638984972829602.52440240310220173.4079291184
3420173.4079291184914.163387375931302.601118936782611.56226843914919561.8456606793
3519561.8456606793914.163387375931293.427684910191620.73570246573918941.1099582135
3618941.1099582135914.163387375931284.116649373209630.04673800272218311.0632202108
3718311.0632202108914.163387375931274.665948303165639.49743907276617671.5657811381
3817671.5657811381914.163387375931265.073486717076649.08990065885517022.4758804792
3917022.4758804792914.163387375931255.337138207198658.82624916873316363.6496313105
4016363.6496313105914.163387375931245.45474446966668.70864290627115694.9409884042
4115694.9409884042914.163387375931235.424114826062678.73927254986815016.2017158543
4215016.2017158543914.163387375931225.243025737822688.92036163810914327.2813542162
4314327.2813542162914.163387375931214.909220313249699.25416706268213628.0271871535
4413628.0271871535914.163387375931204.420407807309709.74297956862212918.2842075849
4512918.2842075849914.163387375931193.77426311378720.3891242621512197.8950833228
4612197.8950833228914.163387375931182.968426249839731.19496112609211466.7001221967
4711466.7001221967914.163387375931172.000501832963742.16288554296810724.5372366537
4810724.5372366537914.163387375931160.868058549809753.2953288261219971.24190782758
499971.24190782758914.163387375931149.568628617416764.5947587585149206.64714906907
509206.64714906907914.163387375931138.099707236042776.0636801398898430.58346892918
518430.58346892918914.163387375931126.458752033943787.7046353419877642.87883358719
527642.87883358719914.163387375931114.643182503816799.5202048721156843.35862871508
536843.35862871508914.163387375931102.65037943073811.5130079452016031.84562076988
546031.84562076988914.16338737593190.4776843115466823.6857030643845208.15991770549
555208.15991770549914.16338737593178.1223987655936836.0409886103374372.11892909516
564372.11892909516914.16338737593165.5817839364341848.5816034394973523.53732565566
573523.53732565566914.16338737593152.8530598848316861.3103274910992662.22699816456
582662.22699816456914.16338737593139.9334049724752874.2299824034561787.9970157611
591787.9970157611914.16338737593126.8199552364267887.343432139504900.653583621601
60900.653583621601914.16338737593113.5098037543298900.6535836216010

Example #3

In this example the principal amount is 25,000, the first period is 1.5 times the length of a regular period, the periodic rate is .75% and there will be a 5,000 balance at the end of the amortization. Interest is calculated using the US rule.

SELECT *
FROM wct.ODDFSCHED(   0.0075, --@Rate
                      60,     --@Nper
                      -25000, --@PV
                      5000,   --@FV
                      1.5,    --@FirstPeriod
                      'U'     --@IntRule
                  );

This produces the following result.

num_pmtamt_prin_initamt_pmtamt_int_payamt_prin_payamt_prin_end
0000025000
125000546.417104527081281.25265.16710452708124734.8328954729
224734.8328954729452.667104527077185.51124671605267.15585781102724467.6770376619
324467.6770376619452.667104527077183.507577782457269.15952674462124198.5175109173
424198.5175109173452.667104527077181.488881331875271.17822319520223927.3392877221
523927.3392877221452.667104527077179.455044657916273.21205986916223654.1272278529
623654.1272278529452.667104527077177.405954208894275.26115031818323378.8660775347
723378.8660775347452.667104527077175.341495581509277.32560894556823101.5404685892
823101.5404685892452.667104527077173.261553514414279.40555101266422822.1349175765
922822.1349175765452.667104527077171.166011881825281.50109264525222540.6338249312
1022540.6338249312452.667104527077169.054753686978283.612350840122257.0214740911
1122257.0214740911452.667104527077166.927661055681285.73944347139721971.2820306197
1221971.2820306197452.667104527077164.784615229651287.88248929742621683.3995413223
1321683.3995413223452.667104527077162.625496559911290.04160796716721393.3579333552
1421393.3579333552452.667104527077160.450184500165292.21692002691321101.1410133282
1521101.1410133282452.667104527077158.258557599962294.40854692711620806.7324664011
1620806.7324664011452.667104527077156.050493498001296.61661102907620510.115855372
1720510.115855372452.667104527077153.82586891529298.84123561178820211.2746197603
1820211.2746197603452.667104527077151.584559648199301.08254487887819910.1920748814
1919910.1920748814452.667104527077149.326440561613303.34066396546419606.8514109159
2019606.8514109159452.667104527077147.051385581864305.61571894521319301.2356919707
2119301.2356919707452.667104527077144.759267689773307.90783683730518993.3278551334
2218993.3278551334452.667104527077142.449958913497310.2171456135818683.1107095198
2318683.1107095198452.667104527077140.123330321399312.54377420567818370.5669353141
2418370.5669353141452.667104527077137.779252014854314.88785251222418055.6790828019
2518055.6790828019452.667104527077135.417593121008317.24951140606917738.4295713958
2617738.4295713958452.667104527077133.038221785467319.6288827416117418.8006886542
2717418.8006886542452.667104527077130.641005164903322.02609936217417096.7745892921
2817096.7745892921452.667104527077128.225809419687324.4412951073916772.3332941847
2916772.3332941847452.667104527077125.792499706385326.87460482069216445.458689364
3016445.458689364452.667104527077123.340940170226329.32616435685116116.1325250071
3116116.1325250071452.667104527077120.870993937555331.79611058952315784.3364144176
3215784.3364144176452.667104527077118.382523108121334.28458141895715450.0518329986
3315450.0518329986452.667104527077115.875388747488336.79171577958915113.2601172191
3415113.2601172191452.667104527077113.349450879141339.31765364793714773.9424635711
3514773.9424635711452.667104527077110.804568476786341.86253605029214432.0799275208
3614432.0799275208452.667104527077108.240599456399344.42650507067814087.6534224502
3714087.6534224502452.667104527077105.657400668377347.00970385870113740.6437185915
3813740.6437185915452.667104527077103.054827889427349.6122766376513391.0314419538
3913391.0314419538452.667104527077100.43273581466352.23436871241813038.7970732414
4013038.7970732414452.66710452707797.7909780493007354.87612647777712683.9209467636
4112683.9209467636452.66710452707795.1294071007266357.53769742635112326.3832493373
4212326.3832493373452.66710452707792.4478743700235360.21923015705411966.1640191802
4311966.1640191802452.66710452707789.7462301438515362.92087438322611603.243144797
4411603.243144797452.66710452707787.0243235859722365.64278094110511237.6003638559
4511237.6003638559452.66710452707784.282002728916368.38510179816110869.2152620577
4610869.2152620577452.66710452707781.5191144654324371.14799006164510498.0672719961
4710498.0672719961452.66710452707778.7355045399651373.93159998711210124.135672009
4810124.135672009452.66710452707775.9310175400639376.7360869870149747.39958502194
499747.39958502194452.66710452707773.1054968876558379.5616076394229367.83797738252
509367.83797738252452.66710452707770.2587848303735382.4083196967048985.42965768581
518985.42965768581452.66710452707767.3907224326355385.2763820944428600.15327559137
528600.15327559137452.66710452707764.5011495669348388.1659549601438211.98732063123
538211.98732063123452.66710452707761.5899049047354391.0771996223427820.91012100889
547820.91012100889452.66710452707758.656825907559394.0102786195187426.89984238937
557426.89984238937452.66710452707755.7017488179187396.9653557091597029.93448668021
567029.93448668021452.66710452707752.7245086500913399.9425958769866629.99189080322
576629.99189080322452.66710452707749.7249391810316402.9421653460466227.04972545718
586227.04972545718452.66710452707746.7028729409255405.9642315861525821.08549387102
595821.08549387102452.66710452707743.6581412040238409.0089633230545412.07653054797
605412.07653054797452.66710452707740.5905739791066412.0765305479715000

See Also

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

ODDFPMTSCHED - Amortization schedule for an annuity with odd first period

PMT - Calculate the periodic payment for an annuity

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

PV - Present value of an annuity