{
  "category": "Financial functions",
  "display_name": "DB",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.DB",
  "implementation_state": {
    "answer_bank": {
      "excel_builds": [
        "20430"
      ],
      "larger_numeric": 0,
      "last_bit": 0,
      "matched": 2034,
      "other_mismatch": 0,
      "refused": 0,
      "rows": 2034,
      "unread": 0,
      "worst_ulp": 0
    },
    "detail": "Recorded: 2,034 in the answer bank and 11 workbook cells.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "matches",
    "state_label": "Matches every recorded Excel answer",
    "summary": "Matches all 2,045 recorded answers",
    "workbook_corpus": {
      "cells": 11,
      "matched": 11
    }
  },
  "implementations": [
    {
      "commit": "9e1884369a678158dd82d3d74188daf986995e87",
      "flavour": "excel-compatibility-candidate",
      "language": "Rust",
      "name": "CalcFunc",
      "own_code": [
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/financial.rs#L289-L294",
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/ported/depreciation_family.rs#L3-L17",
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/ported/depreciation_family.rs#L98-L143",
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/ported/depreciation_family.rs#L145-L215"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "decimal::low32",
        "decimal::Natural::zero",
        "decimal::Natural::from_u64",
        "decimal::Natural::normalize",
        "decimal::Natural::is_zero",
        "decimal::Natural::mul_add_small",
        "decimal::Natural::times_pow5",
        "decimal::Natural::times_pow2",
        "decimal::ExactDecimal::read",
        "decimal::ExactDecimal::binary",
        "ported/depreciation_family::validate_finite",
        "ported/depreciation_family::publish_depreciation",
        "ported/depreciation_family::depreciation_integer_power",
        "ported/excel_numeric::backend::sqrt",
        "ported/excel_numeric::binary_with",
        "ported/excel_numeric::excel_pow_positive",
        "ported/excel_numeric::excel_pow_chain",
        "ported/excel_numeric::excel_x87_sub",
        "ported/excel_numeric::excel_x87_mul",
        "ported/excel_numeric::excel_x87_div",
        "ported/excel_numeric/x87::mul",
        "ported/excel_numeric/x87::sub",
        "ported/excel_numeric/x87::div",
        "ported/excel_numeric/x87_chains::pow2_positive",
        "ported/excel_numeric/x87_chains::pow2",
        "ported/excel_numeric/x87_chains::exp_ext",
        "ported/excel_numeric/x87_chains::exp_with",
        "ported/excel_numeric/x87_chains::excel_exp",
        "ported/excel_numeric/x87_chains::log_with",
        "ported/excel_numeric/x87_chains::excel_log"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/financial.rs#L289-L294",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 2,045 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.DB.json",
  "name": "DB",
  "notes": [],
  "schema": "efh.function-reference/v1",
  "section_order": [
    "what-it-does",
    "try-it",
    "quirks",
    "how-to-implement",
    "version-differences",
    "alternatives"
  ],
  "sections": {
    "alternatives": "\n### Relationships\n\n\n- **[DDB](FUNC.DDB.md)** — the other declining-balance function. The contrast is sharp and worth\n  learning: `DDB` takes the rate as a `factor` and derives nothing; `DB` derives the rate from\n  the salvage ratio and rounds it. `DDB` clamps each charge so the book value never falls below\n  `salvage`; `DB` has no clamp and relies on the rate to land near it. `DDB` has no\n  first-year proration; `DB` has `month`.\n- **`VDB`** — the general declining-balance function, with a rate `factor`, a period *range*, and\n  an optional switch to straight line. The most flexible member of the family.\n- **`SLN`** — straight line, `(cost − salvage)/life`, the flat comparison every declining-balance\n  schedule is measured against.\n- **`SYD`** — sum-of-years-digits, an accelerated schedule that does exhaust `cost − salvage`\n  exactly, unlike `DB`.\n- **[AMORDEGRC](FUNC.AMORDEGRC.md)** and **[AMORLINC](FUNC.AMORLINC.md)** — the French\n  date-prorated pair. They answer the same accounting question with a date interval instead of a\n  `month` count and with 0-based periods.\n- **Confused with**: `DDB` (above), and with the assumption that a `DB` schedule sums to\n  `cost − salvage`. It does not.\n\n\n",
    "how-to-implement": "\n### Numerical notes\n\n1. **The rounding of `rate` dominates everything.** Three decimal places is coarse: on a\n   ten-period asset the difference between a rate of 0.2065 and its rounded 0.207 compounds\n   through the whole schedule. Any implementation must round at exactly the same point — after\n   forming `1 − ratio^(1/life)`, before the first charge — and with the same tie rule.\n2. **`ratio^(1/life)` is a general power** and is the only transcendental in the function. It\n   is evaluated as `exp(ln(ratio)/life)` on most platforms, so `DB` inherits whatever `pow` the\n   host provides — the same dependency the Handbook's research record traced through the bond and\n   distribution families to a single shared library routine. The rounding to three decimals\n   mercifully hides the last-bit differences, but only until the fourth decimal sits near a tie.\n4. **The stub-year branch is decided by `floor(life)`**, so a fractional `life` moves it. This is\n   an implementation decision with no documentary support.\n\n\n",
    "quirks": "\n### The rounded rate\n\n\n`rate` is **rounded to three decimal places** before any charge is computed. Microsoft documents\nthis explicitly, and it is not a display convention: the rounded rate is what the schedule uses,\nso it changes every number the function returns.\n\nTwo consequences follow, and both are visible in ordinary use:\n\n1. **The schedule does not land on `salvage`.** The exact rate would; a rate rounded to three\n   decimals will not. A `DB` schedule summed over its whole life leaves a residual book value\n   that is above or below `salvage` depending on which way the rounding went. Anyone reconciling\n   a `DB` column against `cost − salvage` will find a discrepancy, and it is by construction.\n2. **The function is a step function of its inputs.** Nudge `salvage`, `cost` or `life` slightly\n   and `rate` may not change at all — or may jump by 0.001, moving every subsequent charge. `DB`\n   is therefore piecewise-constant in a way none of its siblings are, and small input errors\n   produce either no error or a discontinuous one.\n\n\n### Result and edge cases\n\n\nReturns a `Number`: the charge for the requested period, in the units of `cost`.\n\n- **`salvage` = 0.** The ratio is 0, `0^(1/life)` is 0, and the rate is exactly 1 — so the first\n  period writes off the entire asset (prorated by `month`) and later periods charge nothing. The\n  formula is doing what it says; the method simply has no meaning when the target salvage is\n  zero. Microsoft's page does not flag this. If Excel special-cases it, that is a divergence\n  worth recording.\n- **`salvage` close to `cost`** gives a rate near 0, which rounds to 0.000 and produces a\n  schedule of zeros. Again the rounding, not the mathematics.\n- **`period` = `life` + 1 with `month` < 12** is the stub year and uses the last-period formula.\n- **Fractional `life`** is accepted; the \"last full regular period\" is taken as its floor, which\n  moves where the stub-year formula applies.\n- Empty, missing and error arguments follow the shared call model; see\n  [The value universe](../model/01-value-universe.md).\n\n\n\n### Errors\n\n\n**Microsoft's Learn page documents no error conditions for this function** — it carries the\nparameter table and the three formulas, and stops. There is no published statement of what\nhappens with a negative `cost`, a `month` of 13, or a `period` beyond the schedule.\n\nNote that `salvage` > `cost` is **not** rejected: the ratio exceeds 1, the power is above 1, and\nthe rate goes negative — producing negative depreciation, that is, appreciation. Whether Excel\nadmits that is unverified, and the documentation is silent.\n\n\n",
    "sources": "- Microsoft Learn, **WorksheetFunction.Db method (Excel)** —\n  <https://learn.microsoft.com/en-us/office/vba/api/excel.worksheetfunction.db>. Source of the\n  parameter table with its quoted descriptions, the `month` default, the ordinary-period formula\n  with the rate derivation and its three-decimal rounding, and the first-period and last-period\n  formulas. This page documents no error conditions.\n- Microsoft Learn, **WorksheetFunction.Ddb method (Excel)** —\n  <https://learn.microsoft.com/en-us/office/vba/api/excel.worksheetfunction.ddb>. Cited for the\n  sibling's formula and defaults in the comparison above.\n- Microsoft 365 support, **DB function** —\n  <https://support.microsoft.com/en-us/office/db-function-354e7d28-5f93-4ff1-8a52-eb4ee549d9d7>.\n  The worksheet-surface page; **not retrieved** for this entry (the host returned HTTP 403), so\n  nothing here is quoted from it.\n- Handbook, `content/lastbit/MATERIAL_W109_PRIMITIVES.md` §19 — the recorded identification of a\n  single shared host `pow` routine underneath several unrelated Excel function families.\n- Handbook chapters [01 the value universe](../model/01-value-universe.md),\n  [02 coercion and lifting](../model/02-coercion-and-lifting.md),\n  [06 claim language](../model/06-claim-language.md).\n- `data/functions/FUNC.DB.json`, `data/presence/FUNC.DB.json`, `data/battery/FUNC.DB.json`.\n\n",
    "version-differences": "The recorded environments below distinguish a reading from a same-input comparison. Counts describe captured inputs in each environment; overlapping captures and comparisons are not totals of unique worksheet calls.\n\n| Excel 16.0 build | Platform and CPU | Captured inputs |\n|---|---|---:|\n| 20430 | Windows, 64-bit, CPU not recorded | 129,326 |\n\nThe record contains no same-input comparison between these environments. Reading different inputs on different builds does not establish either a version change or cross-build agreement.\n\n[Recorded environments and comparison details](https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.DB.json).",
    "what-it-does": "\n`DB(cost, salvage, life, period, [month])` returns the depreciation charge for **one period**\nunder the fixed-declining-balance method.\n\n\"Fixed\" means the *rate* is fixed, not the charge: a constant fraction of the remaining book\nvalue is written off each period, so charges fall geometrically. Microsoft's Learn page states\nthe whole schedule in three formulas.\n\nThe ordinary period:\n\n>     charge = (cost − total depreciation from prior periods) × rate\n>     where rate = 1 − (salvage / cost) ^ (1 / life),  rounded to three decimal places\n\nThe first period, prorated by the number of months the asset was held in the first year:\n\n>     charge = cost × rate × month / 12\n\nAnd the last period — the extra stub period that exists only when `month` < 12:\n\n>     charge = ((cost − total depreciation from prior periods) × rate × (12 − month)) / 12\n\nThose three formulas are quoted from Microsoft. Together they define a schedule of `life`\nperiods when `month` is 12, and `life + 1` periods otherwise: the first and last are partial\nyears that sum to one full year of depreciation.\n\nThe **derivation of `rate`** is the idea worth pausing on. Solving\n`salvage = cost × (1 − rate)^life` for `rate` gives exactly the formula above: it is the constant\nrate that would depreciate the asset from `cost` down to precisely `salvage` over `life` periods.\n`DB` is therefore the declining-balance method that *targets* the salvage value, rather than one\nthat stops when it reaches it.\n\nExcept that it does not quite reach it, because of the rounding.\n\n\n\n### Arguments\n\n\n`DB(cost, salvage, life, period, [month])`\n\n| Argument | Meaning (Microsoft's wording) | Required? |\n|---|---|---|\n| `cost` | \"The initial cost of the asset.\" | Required |\n| `salvage` | \"The value at the end of the depreciation (sometimes called the salvage value of the asset).\" | Required |\n| `life` | \"The number of periods over which the asset is being depreciated (sometimes called the useful life of the asset).\" | Required |\n| `period` | \"The period for which you want to calculate the depreciation. Period must use the same units as life.\" | Required |\n| `month` | \"The number of months in the first year. If month is omitted, it is assumed to be 12.\" | Optional, defaults to 12 |\n\n**`period` is 1-based.** Period 1 is the first (possibly prorated) year. This is the opposite of\n[AMORLINC](FUNC.AMORLINC.md) and [AMORDEGRC](FUNC.AMORDEGRC.md), which number depreciation\nperiods from 0, and mixing the two conventions in one model is a reliable way to produce a\nplausible wrong schedule.\n\n**`month` is not a date.** It is a count of months in the first *year*, so it prorates by\ntwelfths regardless of the calendar. `DB` therefore needs no day-count `basis` and has none —\nwhich is exactly why it is not interchangeable with the French depreciation pair, which prorate\nby an actual date interval.\n\n**`month` < 12 adds a period.** The schedule then runs to `life + 1`, with the last period\ntaking the complementary `(12 − month)/12` fraction. Asking for `period` = `life + 1` with\n`month` = 12 is out of range; asking for it with `month` = 11 is the stub year.\n\n`salvage` and `cost` enter only through their **ratio**, so scaling both by the same factor\nleaves `rate` unchanged and scales every charge linearly.\n\nNumeric slots follow the shared model; see\n[Coercion and lifting](../model/02-coercion-and-lifting.md).\n\n\n"
  },
  "signature": {
    "display": "DB(cost, salvage, life, period, [month])",
    "parameters": [
      {
        "description": null,
        "name": "cost",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "salvage",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "life",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "period",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "month",
        "optional": true,
        "repeats": false
      }
    ],
    "trailing_repeats": false
  },
  "sources": {
    "metadata": {
      "admission": {
        "label": "implemented",
        "reason": null
      },
      "arity": {
        "max": 5,
        "min": 4
      },
      "category": "Financial functions",
      "classification": {
        "arg_preparation_profile": "ValuesOnlyPreAdapter",
        "coercion_lift_profile": "Custom",
        "determinism_class": "Deterministic",
        "error_collapse_profile": "None",
        "fec_dependency_profile": "None",
        "host_interaction_class": "None",
        "kernel_signature_class": "Custom",
        "rich_value_usage": "RichBlind",
        "surface_fec_dependency_profile": "RefOnly",
        "thread_safety_class": "SafePure",
        "volatility_class": "NonVolatile"
      },
      "descriptions": {
        "long": null,
        "short": "Fixed-declining-balance depreciation of an asset for one period",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Returns the depreciation of an asset for a specified period by using the fixed-declining balance method",
        "microsoft_url": "https://support.microsoft.com/en-us/office/db-function-354e7d28-5f93-4ff1-8a52-eb4ee549d9d7"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "قاعدة بيانات"
        },
        {
          "locale": "bg-BG",
          "name": "DB"
        },
        {
          "locale": "cs-CZ",
          "name": "DB"
        },
        {
          "locale": "da-DK",
          "name": "DB"
        },
        {
          "locale": "de-DE",
          "name": "DB"
        },
        {
          "locale": "el-GR",
          "name": "DB"
        },
        {
          "locale": "en-AU",
          "name": "DB"
        },
        {
          "locale": "en-GB",
          "name": "DB"
        },
        {
          "locale": "en-US",
          "name": "DB"
        },
        {
          "locale": "es-ES",
          "name": "NOSQL"
        },
        {
          "locale": "et-EE",
          "name": "DB"
        },
        {
          "locale": "fi-FI",
          "name": "DB"
        },
        {
          "locale": "fr-FR",
          "name": "Base de données"
        },
        {
          "locale": "he-IL",
          "name": "DB"
        },
        {
          "locale": "hr-HR",
          "name": "DB"
        },
        {
          "locale": "hu-HU",
          "name": "KCS2"
        },
        {
          "locale": "id-ID",
          "name": "DB"
        },
        {
          "locale": "it-IT",
          "name": "DB"
        },
        {
          "locale": "ja-JP",
          "name": "DB"
        },
        {
          "locale": "ko-KR",
          "name": "DB"
        },
        {
          "locale": "lt-LT",
          "name": "DB"
        },
        {
          "locale": "lv-LV",
          "name": "DB"
        },
        {
          "locale": "nb-NO",
          "name": "DB"
        },
        {
          "locale": "nl-NL",
          "name": "DB"
        },
        {
          "locale": "pl-PL",
          "name": "DB"
        },
        {
          "locale": "pt-BR",
          "name": "NoSQL"
        },
        {
          "locale": "pt-PT",
          "name": "DB"
        },
        {
          "locale": "ro-RO",
          "name": "DB"
        },
        {
          "locale": "ru-RU",
          "name": "ФУО"
        },
        {
          "locale": "sk-SK",
          "name": "DB"
        },
        {
          "locale": "sl-SI",
          "name": "DB"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "DB"
        },
        {
          "locale": "sv-SE",
          "name": "DB"
        },
        {
          "locale": "th-TH",
          "name": "DB"
        },
        {
          "locale": "tr-TR",
          "name": "DB"
        },
        {
          "locale": "uk-UA",
          "name": "DB"
        },
        {
          "locale": "vi-VN",
          "name": "DB"
        },
        {
          "locale": "zh-CN",
          "name": "DB"
        },
        {
          "locale": "zh-HK",
          "name": "DB"
        },
        {
          "locale": "zh-TW",
          "name": "DB"
        }
      ],
      "signature": {
        "display": "DB(cost, salvage, life, period, [month])",
        "parameters": [
          {
            "description": null,
            "name": "cost",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "salvage",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "life",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "period",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "month",
            "optional": true,
            "repeats": false
          }
        ],
        "trailing_repeats": false
      },
      "surface_name": "DB",
      "version_marker": null,
      "xlcall": {
        "code": "247",
        "symbol": "xlfDb"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/db-function-354e7d28-5f93-4ff1-8a52-eb4ee549d9d7"
  },
  "try_it": {
    "formula": "=DB(1000,100,5,1)"
  },
  "url": "https://handbook.dnacalc.com/functions/DB.html",
  "variants": [],
  "versions": [
    {
      "behaviour": "129,326 captured inputs are indexed for this environment. Capture dates: 2026-09-29 to 2026-09-29. This is a reading count, not a comparison with another build.",
      "excel_build": "16.0 build 20430",
      "platform": "Windows, 64-bit, CPU not recorded",
      "sources": [
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.DB.json"
      ]
    }
  ]
}