curatedapi
Browse the docs

Guides

Finance

Excel functions

Late payments

E-invoices

Accounting

Number checks

VAT and GST

Billing and pricing

Money and currencies

Dates and time

Math

Unit conversion

Everyday

Health

Excel DDB function: double-declining balance depreciation API

Double-declining (or any factor) balance depreciation for one period, as Excel's DDB.

POST https://api.curatedapi.com/v1/calc/excel/ddb

DDB(cost, salvage, life, period, [factor]) = min((cost − prior depreciation)·factor/life, cost − salvage − prior depreciation).

Formula

min(book·factor/life, book − salvage)
  • Arguments are named and ordered as in Excel. Excel computes in binary floating point; this API computes the exact value of the same formula and rounds it once, so it agrees with Excel to the digits Excel can show, and where Excel's own rounding error reaches the 15th digit this answer is the correct one.

Inputs

Send numbers as strings to keep every digit. options sets precision and rounding (see numbers and rounding).

InputTypeDescription
cost required decimal (string) Initial cost of the asset. A ratio of two decimals such as "0.08/12" is accepted. Allowed: >= 0 and <= 1000000000000000.
salvage required decimal (string) Value at the end of its life (can be 0). A ratio of two decimals such as "0.08/12" is accepted. Allowed: >= 0 and <= 1000000000000000.
life required decimal (string) Number of periods over which the asset is depreciated. A ratio of two decimals such as "0.08/12" is accepted. Allowed: > 0 and <= 10000.
period required decimal (string) The period, in the same unit as life. A ratio of two decimals such as "0.08/12" is accepted. Allowed: > 0 and <= 10000.
factor decimal (string)
default 2
Rate at which the balance declines (2 is double-declining). A ratio of two decimals such as "0.08/12" is accepted. Allowed: > 0 and <= 1000.
options.rounding half_even | half_up | half_down | up | down | ceiling | floor Rounding mode applied once to each result. Default half_even.
options.decimals integer Round results to this many digits after the decimal point.
options.significant_digits integer Round results to this many significant digits.

Result

Under result in the answer, next to exactness, precision, inputs, formula, references and warnings.

ResultTypeDescription
ddbdecimal (string)Depreciation in that period.

Examples

Microsoft's example: first day

Requestcurl
curl https://api.curatedapi.com/v1/calc/excel/ddb \
  -H "Authorization: Bearer $CURATEDAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "cost": "2400",
    "salvage": "300",
    "life": "3650",
    "period": "1",
    "options": {"decimals": 2}
  }'
200 OKResponse
{
  "calculator": "excel/ddb@1",
  "result": {
    "ddb": "1.32"
  },
  "exactness": {
    "ddb": "rounded"
  },
  "precision": {
    "rounding": "half_even",
    "decimals": 2
  },
  "inputs": {
    "cost": "2400",
    "salvage": "300",
    "life": "3650",
    "period": "1",
    "factor": "2"
  },
  "formula": "min(book·factor/life, book − salvage)",
  "references": [
    {
      "title": "Microsoft Excel DDB function",
      "url": "https://support.microsoft.com/en-us/excel/functions/ddb-function"
    }
  ],
  "warnings": []
}

Microsoft's example: first year

Requestcurl
curl https://api.curatedapi.com/v1/calc/excel/ddb \
  -H "Authorization: Bearer $CURATEDAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "cost": "2400",
    "salvage": "300",
    "life": "10",
    "period": "1",
    "factor": "2",
    "options": {"decimals": 2}
  }'
200 OKResponse
{
  "calculator": "excel/ddb@1",
  "result": {
    "ddb": "480.00"
  },
  "exactness": {
    "ddb": "exact"
  },
  "precision": {
    "rounding": "half_even",
    "decimals": 2
  },
  "inputs": {
    "cost": "2400",
    "salvage": "300",
    "life": "10",
    "period": "1",
    "factor": "2"
  },
  "formula": "min(book·factor/life, book − salvage)",
  "references": [
    {
      "title": "Microsoft Excel DDB function",
      "url": "https://support.microsoft.com/en-us/excel/functions/ddb-function"
    }
  ],
  "warnings": []
}

Microsoft's example: second year, factor 1.5

Requestcurl
curl https://api.curatedapi.com/v1/calc/excel/ddb \
  -H "Authorization: Bearer $CURATEDAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "cost": "2400",
    "salvage": "300",
    "life": "10",
    "period": "2",
    "factor": "1.5",
    "options": {"decimals": 2}
  }'
200 OKResponse
{
  "calculator": "excel/ddb@1",
  "result": {
    "ddb": "306.00"
  },
  "exactness": {
    "ddb": "exact"
  },
  "precision": {
    "rounding": "half_even",
    "decimals": 2
  },
  "inputs": {
    "cost": "2400",
    "salvage": "300",
    "life": "10",
    "period": "2",
    "factor": "1.5"
  },
  "formula": "min(book·factor/life, book − salvage)",
  "references": [
    {
      "title": "Microsoft Excel DDB function",
      "url": "https://support.microsoft.com/en-us/excel/functions/ddb-function"
    }
  ],
  "warnings": []
}

Microsoft's example: tenth year

Requestcurl
curl https://api.curatedapi.com/v1/calc/excel/ddb \
  -H "Authorization: Bearer $CURATEDAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "cost": "2400",
    "salvage": "300",
    "life": "10",
    "period": "10",
    "options": {"decimals": 2}
  }'
200 OKResponse
{
  "calculator": "excel/ddb@1",
  "result": {
    "ddb": "22.12"
  },
  "exactness": {
    "ddb": "rounded"
  },
  "precision": {
    "rounding": "half_even",
    "decimals": 2
  },
  "inputs": {
    "cost": "2400",
    "salvage": "300",
    "life": "10",
    "period": "10",
    "factor": "2"
  },
  "formula": "min(book·factor/life, book − salvage)",
  "references": [
    {
      "title": "Microsoft Excel DDB function",
      "url": "https://support.microsoft.com/en-us/excel/functions/ddb-function"
    }
  ],
  "warnings": []
}

References

Results follow each calculator's documented rules and the sources listed. They are not financial, tax or legal advice. Check that the rules fit your case before you rely on a result. See the terms.

Errors share one format; see errors. Billing, retries and batches work the same for every endpoint.