{
  "category": "Financial functions",
  "display_name": "COUPPCD",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.COUPPCD",
  "implementation_state": {
    "answer_bank": {
      "excel_builds": [
        "20131",
        "20430",
        "?"
      ],
      "larger_numeric": 0,
      "last_bit": 0,
      "matched": 5584,
      "other_mismatch": 0,
      "refused": 0,
      "rows": 5584,
      "unread": 0,
      "worst_ulp": 0
    },
    "detail": "Recorded: 5,584 in the answer bank and 7 workbook cells.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "matches",
    "state_label": "Matches every recorded Excel answer",
    "summary": "Matches all 5,591 recorded answers",
    "workbook_corpus": {
      "cells": 7,
      "matched": 7
    }
  },
  "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/bonds.rs#L187-L190",
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/ported/coupon_family.rs#L374-L383"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "catalogue/bonds::basis",
        "catalogue/bonds::date_out",
        "catalogue/bonds::coupon_args",
        "catalogue/financial::date_1900",
        "locale::days_from_civil",
        "locale::civil_from_days",
        "locale::excel_serial_from_ymd",
        "locale::ymd_from_excel_serial",
        "ported/coupon_family::max_excel_serial",
        "ported/coupon_family::days_in_month",
        "ported/coupon_family::days_from_civil",
        "ported/coupon_family::excel_serial_from_ymd_unbounded_1900",
        "ported/coupon_family::parse_basis",
        "ported/coupon_family::parse_frequency",
        "ported/coupon_family::check_coupon_dates",
        "ported/coupon_family::parse_coupon_date",
        "ported/coupon_family::parse_coupon_context",
        "ported/coupon_family::coupon_date_before_maturity",
        "ported/coupon_family::locate_coupon_period"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/bonds.rs#L187-L190",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 5,591 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.COUPPCD.json",
  "name": "COUPPCD",
  "notes": [
    {
      "basis": "All 5,584 rows of three recorded sets: 3,012 and 1,512 rows from build 20430, 1,060 from build 20131. The rule was recomputed independently from the calendar and matched all 5,566 number rows with settlement at serial 61 or later, on every basis. The other two number rows have settlement 0 and basis 0, and read 180. In a study of 42 ways to walk and measure the schedule, this was the only one to match all 965 rows with basis exactly 1.",
      "documentation": null,
      "evidence": [
        {
          "commit": "14910720ec396f241b46460ecab093f71733c5f5",
          "locator": "coupdays_kernel",
          "note": "the rule as implemented",
          "path": "crates/calc-func/src/ported/coupon_family.rs",
          "repository": "DnaCalc"
        },
        {
          "commit": "14910720ec396f241b46460ecab093f71733c5f5",
          "locator": "coupdays_actual_actual_uses_its_recorded_calendar_interval",
          "note": "six recorded calls pinned",
          "path": "crates/calc-func/tests/f3_financial.rs",
          "repository": "DnaCalc"
        },
        {
          "commit": "19d810d45ad46fe5d2ddf0f4f582dd603a881a91",
          "locator": null,
          "note": "the 42 schedule variants compared on 965 basis 1 rows",
          "path": "evidence/round24/coupon/coupon-calendar-summary.json",
          "repository": "DnaCalc-Research"
        },
        {
          "commit": "19d810d45ad46fe5d2ddf0f4f582dd603a881a91",
          "locator": null,
          "note": "5,584 of 5,584 rows matched",
          "path": "evidence/round24/coupon/coupdays-registered-delta.json",
          "repository": "DnaCalc-Research"
        },
        {
          "commit": "2d0eddcac86413014643af81d646581d54ba57bc",
          "locator": "COUPDAYS",
          "note": "matched rows per function",
          "path": "crates/calc-func/witness-status.tsv",
          "repository": "DnaCalc"
        },
        {
          "commit": "4d5320dfdc385354469b4d506153357bb932ab08",
          "locator": null,
          "note": "1,512 recorded rows, inputs read again",
          "path": "runs/w111-5-20260924/answers/answers-w1115-coupdays.json.gz",
          "repository": "CalcFunc-Evidence"
        }
      ],
      "functions": [
        "FUNC.COUPDAYS",
        "FUNC.COUPNCD",
        "FUNC.COUPPCD"
      ],
      "inferred": "The rule reproduces every recorded row; that Excel's code works this way is inferred. For basis 1 no settlement or maturity before serial 61, where Excel's calendar differs from the Gregorian one, is in the recorded rows.",
      "kind": "quirk",
      "note_id": "FN-COUPDAYS-001",
      "open": [],
      "recorded_on": "2026-11-04",
      "repros": [
        {
          "call": "COUPDAYS(35748, 35976, 2, 1)",
          "correct": null,
          "excel": {
            "bits": "0x4066e00000000000",
            "display": "183",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "settlement",
              "value": {
                "bits": "0x40e1748000000000",
                "display": "35748",
                "kind": "number"
              }
            },
            {
              "name": "maturity",
              "value": {
                "bits": "0x40e1910000000000",
                "display": "35976",
                "kind": "number"
              }
            },
            {
              "name": "frequency",
              "value": {
                "bits": "0x4000000000000000",
                "display": "2",
                "kind": "number"
              }
            },
            {
              "name": "basis",
              "value": {
                "bits": "0x3ff0000000000000",
                "display": "1",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20430, Windows 64-bit, AMD Ryzen 7 4800H",
          "source": {
            "commit": "4d5320dfdc385354469b4d506153357bb932ab08",
            "locator": "COUPDAYS|0x40e1748000000000|0x40e1910000000000|0x4000000000000000|0x3ff0000000000000",
            "note": null,
            "path": "cache/oracle-20430/build-20430/COUPDAYS.jsonl.gz",
            "repository": "CalcFunc-Evidence"
          }
        },
        {
          "call": "COUPDAYS(36452, 36891, 4, 1)",
          "correct": null,
          "excel": {
            "bits": "0x4056c00000000000",
            "display": "91",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "settlement",
              "value": {
                "bits": "0x40e1cc8000000000",
                "display": "36452",
                "kind": "number"
              }
            },
            {
              "name": "maturity",
              "value": {
                "bits": "0x40e2036000000000",
                "display": "36891",
                "kind": "number"
              }
            },
            {
              "name": "frequency",
              "value": {
                "bits": "0x4010000000000000",
                "display": "4",
                "kind": "number"
              }
            },
            {
              "name": "basis",
              "value": {
                "bits": "0x3ff0000000000000",
                "display": "1",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20430, Windows 64-bit, AMD Ryzen 7 4800H",
          "source": {
            "commit": "4d5320dfdc385354469b4d506153357bb932ab08",
            "locator": "COUPDAYS|0x40e1cc8000000000|0x40e2036000000000|0x4010000000000000|0x3ff0000000000000",
            "note": null,
            "path": "cache/oracle-20430/build-20430/COUPDAYS.jsonl.gz",
            "repository": "CalcFunc-Evidence"
          }
        },
        {
          "call": "COUPDAYS(36812, 47907, 4, 1)",
          "correct": null,
          "excel": {
            "bits": "0x4057000000000000",
            "display": "92",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "settlement",
              "value": {
                "bits": "0x40e1f98000000000",
                "display": "36812",
                "kind": "number"
              }
            },
            {
              "name": "maturity",
              "value": {
                "bits": "0x40e7646000000000",
                "display": "47907",
                "kind": "number"
              }
            },
            {
              "name": "frequency",
              "value": {
                "bits": "0x4010000000000000",
                "display": "4",
                "kind": "number"
              }
            },
            {
              "name": "basis",
              "value": {
                "bits": "0x3ff0000000000000",
                "display": "1",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20430, Windows 64-bit, AMD Ryzen 7 4800H",
          "source": {
            "commit": "4d5320dfdc385354469b4d506153357bb932ab08",
            "locator": "COUPDAYS|0x40e1f98000000000|0x40e7646000000000|0x4010000000000000|0x3ff0000000000000",
            "note": null,
            "path": "cache/oracle-20430/build-20430/COUPDAYS.jsonl.gz",
            "repository": "CalcFunc-Evidence"
          }
        },
        {
          "call": "COUPDAYS(37015, 38137, 4, 1)",
          "correct": null,
          "excel": {
            "bits": "0x4056400000000000",
            "display": "89",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "settlement",
              "value": {
                "bits": "0x40e212e000000000",
                "display": "37015",
                "kind": "number"
              }
            },
            {
              "name": "maturity",
              "value": {
                "bits": "0x40e29f2000000000",
                "display": "38137",
                "kind": "number"
              }
            },
            {
              "name": "frequency",
              "value": {
                "bits": "0x4010000000000000",
                "display": "4",
                "kind": "number"
              }
            },
            {
              "name": "basis",
              "value": {
                "bits": "0x3ff0000000000000",
                "display": "1",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20430, Windows 64-bit, AMD Ryzen 7 4800H",
          "source": {
            "commit": "4d5320dfdc385354469b4d506153357bb932ab08",
            "locator": "COUPDAYS|0x40e212e000000000|0x40e29f2000000000|0x4010000000000000|0x3ff0000000000000",
            "note": null,
            "path": "cache/oracle-20430/build-20430/COUPDAYS.jsonl.gz",
            "repository": "CalcFunc-Evidence"
          }
        },
        {
          "call": "COUPDAYS(38044, 38411, 2, 1)",
          "correct": null,
          "excel": {
            "bits": "0x4067000000000000",
            "display": "184",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "settlement",
              "value": {
                "bits": "0x40e2938000000000",
                "display": "38044",
                "kind": "number"
              }
            },
            {
              "name": "maturity",
              "value": {
                "bits": "0x40e2c16000000000",
                "display": "38411",
                "kind": "number"
              }
            },
            {
              "name": "frequency",
              "value": {
                "bits": "0x4000000000000000",
                "display": "2",
                "kind": "number"
              }
            },
            {
              "name": "basis",
              "value": {
                "bits": "0x3ff0000000000000",
                "display": "1",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20430, Windows 64-bit, AMD Ryzen 7 4800H",
          "source": {
            "commit": "4d5320dfdc385354469b4d506153357bb932ab08",
            "locator": "COUPDAYS|0x40e2938000000000|0x40e2c16000000000|0x4000000000000000|0x3ff0000000000000",
            "note": null,
            "path": "cache/oracle-20430/build-20430/COUPDAYS.jsonl.gz",
            "repository": "CalcFunc-Evidence"
          }
        },
        {
          "call": "COUPDAYS(34911, 35216, 2, 1)",
          "correct": null,
          "excel": {
            "bits": "0x4066e00000000000",
            "display": "183",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "settlement",
              "value": {
                "bits": "0x40e10be000000000",
                "display": "34911",
                "kind": "number"
              }
            },
            {
              "name": "maturity",
              "value": {
                "bits": "0x40e1320000000000",
                "display": "35216",
                "kind": "number"
              }
            },
            {
              "name": "frequency",
              "value": {
                "bits": "0x4000000000000000",
                "display": "2",
                "kind": "number"
              }
            },
            {
              "name": "basis",
              "value": {
                "bits": "0x3ff0000000000000",
                "display": "1",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20430, Windows 64-bit, AMD Ryzen 7 4800H",
          "source": {
            "commit": "4d5320dfdc385354469b4d506153357bb932ab08",
            "locator": "COUPDAYS|0x40e10be000000000|0x40e1320000000000|0x4000000000000000|0x3ff0000000000000",
            "note": null,
            "path": "cache/oracle-20430/build-20430/COUPDAYS.jsonl.gz",
            "repository": "CalcFunc-Evidence"
          }
        },
        {
          "call": "COUPPCD(44043, 2958465, 2, 1)",
          "correct": null,
          "excel": {
            "bits": "0x40e57d8000000000",
            "display": "44012",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "settlement",
              "value": {
                "bits": "0x40e5816000000000",
                "display": "44043",
                "kind": "number"
              }
            },
            {
              "name": "maturity",
              "value": {
                "bits": "0x4146924080000000",
                "display": "2958465",
                "kind": "number"
              }
            },
            {
              "name": "frequency",
              "value": {
                "bits": "0x4000000000000000",
                "display": "2",
                "kind": "number"
              }
            },
            {
              "name": "basis",
              "value": {
                "bits": "0x3ff0000000000000",
                "display": "1",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20430, Windows 64-bit, AMD Ryzen 7 4800H",
          "source": {
            "commit": "4d5320dfdc385354469b4d506153357bb932ab08",
            "locator": "COUPPCD|0x40e5816000000000|0x4146924080000000|0x4000000000000000|0x3ff0000000000000",
            "note": null,
            "path": "cache/oracle-20430/build-20430/COUPPCD.jsonl.gz",
            "repository": "CalcFunc-Evidence"
          }
        },
        {
          "call": "COUPNCD(44043, 2958465, 2, 1)",
          "correct": null,
          "excel": {
            "bits": "0x40e5948000000000",
            "display": "44196",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "settlement",
              "value": {
                "bits": "0x40e5816000000000",
                "display": "44043",
                "kind": "number"
              }
            },
            {
              "name": "maturity",
              "value": {
                "bits": "0x4146924080000000",
                "display": "2958465",
                "kind": "number"
              }
            },
            {
              "name": "frequency",
              "value": {
                "bits": "0x4000000000000000",
                "display": "2",
                "kind": "number"
              }
            },
            {
              "name": "basis",
              "value": {
                "bits": "0x3ff0000000000000",
                "display": "1",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20430, Windows 64-bit, AMD Ryzen 7 4800H",
          "source": {
            "commit": "4d5320dfdc385354469b4d506153357bb932ab08",
            "locator": "COUPNCD|0x40e5816000000000|0x4146924080000000|0x4000000000000000|0x3ff0000000000000",
            "note": null,
            "path": "cache/oracle-20430/build-20430/COUPNCD.jsonl.gz",
            "repository": "CalcFunc-Evidence"
          }
        },
        {
          "call": "COUPDAYS(44043, 2958465, 2, 1)",
          "correct": null,
          "excel": {
            "bits": "0x4066e00000000000",
            "display": "183",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "settlement",
              "value": {
                "bits": "0x40e5816000000000",
                "display": "44043",
                "kind": "number"
              }
            },
            {
              "name": "maturity",
              "value": {
                "bits": "0x4146924080000000",
                "display": "2958465",
                "kind": "number"
              }
            },
            {
              "name": "frequency",
              "value": {
                "bits": "0x4000000000000000",
                "display": "2",
                "kind": "number"
              }
            },
            {
              "name": "basis",
              "value": {
                "bits": "0x3ff0000000000000",
                "display": "1",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20430, Windows 64-bit, AMD Ryzen 7 4800H",
          "source": {
            "commit": "4d5320dfdc385354469b4d506153357bb932ab08",
            "locator": "COUPDAYS|0x40e5816000000000|0x4146924080000000|0x4000000000000000|0x3ff0000000000000",
            "note": null,
            "path": "cache/oracle-20430/build-20430/COUPDAYS.jsonl.gz",
            "repository": "CalcFunc-Evidence"
          }
        }
      ],
      "schema": "efh.function-note/v1",
      "statement": "On basis 1 (actual/actual) COUPDAYS does not always equal COUPNCD minus COUPPCD. Its rule: start at maturity and step back by 12/frequency months. Each step keeps the day of the month and clamps it to the length of the target month, and the clamped date is the start of the next step, so passing through February lowers the day for every earlier date. Stop at the last date still after settlement, call it next. The answer is the number of actual days from one period before next up to next, and this last step keeps month ends: if next is the last day of its month, the start is the last day of its month. On the other bases the answer is 360/frequency (bases 0, 2, 4) or 365/frequency (basis 3). With this rule, all 5,584 recorded rows match (4,072 distinct inputs): 5,568 numbers and 16 #NUM!, from Excel builds 20131 and 20430. Of the 967 basis 1 rows, 81 (49 distinct inputs) differ from the day count between the dates of a schedule anchored on maturity with month ends kept. For maturity 1998-06-30 with semi-annual coupons, COUPDAYS(35748,35976,2,1) is 183, from 1997-06-30 to 1997-12-30; the anchored schedule gives 184. In one recorded case all three functions were read on the same inputs: COUPNCD(44043,2958465,2,1) less COUPPCD is 44196 - 44012 = 184, and COUPDAYS is 183.",
      "status": "measured",
      "title": "On basis 1 COUPDAYS walks back from maturity by its own rule, not COUPPCD to COUPNCD"
    },
    {
      "basis": "The rule matches all 429 recorded COUPNUM readings (325 #NUM!, 104 counts) when recomputed independently from the calendar, and the 24 COUPNUM readings of the date-boundary sheets. COUPPCD, COUPNCD, COUPDAYS, COUPDAYBS and COUPDAYSNC companions come from the same sheets.",
      "documentation": null,
      "evidence": [
        {
          "commit": "2033d9feb7d9f99817b4b2b34837509bf5af843c",
          "locator": "coupnum_kernel",
          "note": "the limit as implemented",
          "path": "crates/calc-func/src/ported/coupon_family.rs",
          "repository": "DnaCalc"
        },
        {
          "commit": "2d0eddcac86413014643af81d646581d54ba57bc",
          "locator": "delivered_fn4_coupon_counts_at_calendar_start",
          "note": "recorded answers pinned",
          "path": "apps/dna-onecalc/tests/acceptance.rs",
          "repository": "DnaCalc"
        },
        {
          "commit": "2d0eddcac86413014643af81d646581d54ba57bc",
          "locator": null,
          "note": "429 recorded readings",
          "path": "crates/calc-func/tests/captures/fn4_questions/COUPNUM.reading.json",
          "repository": "DnaCalc"
        },
        {
          "commit": "2d0eddcac86413014643af81d646581d54ba57bc",
          "locator": "sheets qd153 to qd236",
          "note": "boundary sheets for all six coupon functions",
          "path": "crates/calc-func/tests/captures/fn4_questions/functions-fn4-date-domain.capture.json",
          "repository": "DnaCalc"
        }
      ],
      "functions": [
        "FUNC.COUPNCD",
        "FUNC.COUPNUM",
        "FUNC.COUPPCD"
      ],
      "inferred": null,
      "kind": "quirk",
      "note_id": "FN-COUPNUM-001",
      "open": [],
      "recorded_on": "2026-11-04",
      "repros": [
        {
          "call": "COUPNUM(33, 400, 2, 0)",
          "correct": null,
          "excel": {
            "bits": null,
            "display": "#NUM!",
            "kind": "error"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "settlement",
              "value": {
                "bits": "0x4040800000000000",
                "display": "33",
                "kind": "number"
              }
            },
            {
              "name": "maturity",
              "value": {
                "bits": "0x4079000000000000",
                "display": "400",
                "kind": "number"
              }
            },
            {
              "name": "frequency",
              "value": {
                "bits": "0x4000000000000000",
                "display": "2",
                "kind": "number"
              }
            },
            {
              "name": "basis",
              "value": {
                "bits": "0x0000000000000000",
                "display": "0",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0.20527.20088, Windows, bitness and CPU not recorded in this reading file",
          "source": {
            "commit": "2d0eddcac86413014643af81d646581d54ba57bc",
            "locator": "fn7-COUPNUM-calendar-boundary-127",
            "note": null,
            "path": "crates/calc-func/tests/captures/fn4_questions/COUPNUM.reading.json",
            "repository": "DnaCalc"
          }
        },
        {
          "call": "COUPNUM(34, 400, 2, 0)",
          "correct": null,
          "excel": {
            "bits": "0x4000000000000000",
            "display": "2",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "settlement",
              "value": {
                "bits": "0x4041000000000000",
                "display": "34",
                "kind": "number"
              }
            },
            {
              "name": "maturity",
              "value": {
                "bits": "0x4079000000000000",
                "display": "400",
                "kind": "number"
              }
            },
            {
              "name": "frequency",
              "value": {
                "bits": "0x4000000000000000",
                "display": "2",
                "kind": "number"
              }
            },
            {
              "name": "basis",
              "value": {
                "bits": "0x0000000000000000",
                "display": "0",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0.20527.20088, Windows, bitness and CPU not recorded in this reading file",
          "source": {
            "commit": "2d0eddcac86413014643af81d646581d54ba57bc",
            "locator": "fn7-COUPNUM-calendar-boundary-128",
            "note": null,
            "path": "crates/calc-func/tests/captures/fn4_questions/COUPNUM.reading.json",
            "repository": "DnaCalc"
          }
        },
        {
          "call": "COUPNUM(0, 367, 2, 0)",
          "correct": null,
          "excel": {
            "bits": null,
            "display": "#NUM!",
            "kind": "error"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "settlement",
              "value": {
                "bits": "0x0000000000000000",
                "display": "0",
                "kind": "number"
              }
            },
            {
              "name": "maturity",
              "value": {
                "bits": "0x4076f00000000000",
                "display": "367",
                "kind": "number"
              }
            },
            {
              "name": "frequency",
              "value": {
                "bits": "0x4000000000000000",
                "display": "2",
                "kind": "number"
              }
            },
            {
              "name": "basis",
              "value": {
                "bits": "0x0000000000000000",
                "display": "0",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0.20527.20088, Windows, bitness and CPU not recorded in this reading file",
          "source": {
            "commit": "2d0eddcac86413014643af81d646581d54ba57bc",
            "locator": "fn7-COUPNUM-calendar-boundary-85",
            "note": null,
            "path": "crates/calc-func/tests/captures/fn4_questions/COUPNUM.reading.json",
            "repository": "DnaCalc"
          }
        },
        {
          "call": "=COUPNUM(0,182,2,0)",
          "correct": null,
          "excel": {
            "bits": null,
            "display": "#NUM!",
            "kind": "error"
          },
          "input_route": "formula-literal",
          "inputs": [],
          "recorded_in": "Excel 16.0.20527.20088 Current Channel, Windows 64-bit (NT 10.0.26200), x86-64, AMD Ryzen 7 4800H, en-ZA",
          "source": {
            "commit": "2d0eddcac86413014643af81d646581d54ba57bc",
            "locator": "sheet qd230, row 20, column 10",
            "note": null,
            "path": "crates/calc-func/tests/captures/fn4_questions/functions-fn4-date-domain.capture.json",
            "repository": "DnaCalc"
          }
        },
        {
          "call": "=COUPNUM(A1,400,2,0)",
          "correct": null,
          "excel": {
            "bits": null,
            "display": "#NUM!",
            "kind": "error"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "A1",
              "value": {
                "bits": "0x0000000000000000",
                "display": "0",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0.20527.20088 Current Channel, Windows 64-bit (NT 10.0.26200), x86-64, AMD Ryzen 7 4800H, en-ZA",
          "source": {
            "commit": "2d0eddcac86413014643af81d646581d54ba57bc",
            "locator": "sheet qd205, row 20, column 10",
            "note": null,
            "path": "crates/calc-func/tests/captures/fn4_questions/functions-fn4-date-domain.capture.json",
            "repository": "DnaCalc"
          }
        },
        {
          "call": "=COUPPCD(A1,400,2,0)",
          "correct": null,
          "excel": {
            "bits": "0x0000000000000000",
            "display": "0",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "A1",
              "value": {
                "bits": "0x0000000000000000",
                "display": "0",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0.20527.20088 Current Channel, Windows 64-bit (NT 10.0.26200), x86-64, AMD Ryzen 7 4800H, en-ZA",
          "source": {
            "commit": "2d0eddcac86413014643af81d646581d54ba57bc",
            "locator": "sheet qd217, row 20, column 10",
            "note": null,
            "path": "crates/calc-func/tests/captures/fn4_questions/functions-fn4-date-domain.capture.json",
            "repository": "DnaCalc"
          }
        },
        {
          "call": "=COUPNCD(A1,400,2,0)",
          "correct": null,
          "excel": {
            "bits": "0x4041000000000000",
            "display": "34",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "A1",
              "value": {
                "bits": "0x0000000000000000",
                "display": "0",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0.20527.20088 Current Channel, Windows 64-bit (NT 10.0.26200), x86-64, AMD Ryzen 7 4800H, en-ZA",
          "source": {
            "commit": "2d0eddcac86413014643af81d646581d54ba57bc",
            "locator": "sheet qd193, row 20, column 10",
            "note": null,
            "path": "crates/calc-func/tests/captures/fn4_questions/functions-fn4-date-domain.capture.json",
            "repository": "DnaCalc"
          }
        }
      ],
      "schema": "efh.function-note/v1",
      "statement": "If the coupon date before settlement, counted back from maturity, falls before 1 January 1900, COUPNUM gives #NUM!. The other coupon functions still answer for the same inputs: COUPPCD returns 0, COUPNCD the next coupon, and COUPDAYS, COUPDAYBS and COUPDAYSNC a day count. With maturity serial 400 (1901-02-03) and semi-annual coupons, the coupon dates are serials 34 and 216: settlement 33 gives #NUM!, settlement 34 gives 2. With maturity 367, settlement 0 gives #NUM! and settlement 1 gives 2. This covers settlement 0 too: COUPNUM(0,m,2,0) was #NUM! for every maturity read.",
      "status": "measured",
      "title": "COUPNUM is #NUM! when the coupon before settlement falls before 1900"
    }
  ],
  "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- **[COUPNCD](FUNC.COUPNCD.md)** — the forward end of the same period, and the page that hosts\n  the shared schedule description.\n- **[COUPDAYBS](FUNC.COUPDAYBS.md)** — the day count from this date to `settlement`. On bases 1,\n  2 and 3 it equals `settlement − COUPPCD`; on the 30/360 bases it does not.\n- **[COUPDAYS](FUNC.COUPDAYS.md)** — the period length. `COUPNCD − COUPPCD` is the *actual*\n  length and equals `COUPDAYS` only under basis 1, and not always there (FN-COUPDAYS-001).\n- **[COUPNUM](FUNC.COUPNUM.md)** — the count of remaining coupons on the same ladder.\n- **[EDATE](FUNC.EDATE.md)** — the general month-stepping function. `EDATE` clamps the day of\n  month but does not make month-ends sticky, so `EDATE(maturity, −n × 12/frequency)` reproduces\n  `COUPPCD` for ordinary maturities and diverges for month-end ones.\n- **[ACCRINT](FUNC.ACCRINT.md)** — the function that does know an issue date, for cases where\n  the notional previous coupon date is the wrong accrual anchor.\n- **Confused with**: \"the date of the last coupon actually paid\", which this function does not\n  answer for a bond issued after the notional date it returns.\n\n\n",
    "how-to-implement": "\n### Numerical notes\n\n1. **The answer is an integer-valued date serial**; there is no floating-point content.\n3. **Month-end anchoring is a modelling decision** with no documentary support, and it is where\n   two careful implementations will part company. State the rule explicitly rather than\n   inheriting it from whatever a date library happens to do.\n4. **Validate `basis` and then ignore it.** Computing this date through a day-count routine\n   would introduce a dependency the function does not have.\n5. **The roll-forward branch** decides the equality case and should be settled before anything\n   else, because it also fixes `COUPDAYBS`'s zero and `COUPNUM`'s count on the same input.\n\n\n",
    "quirks": "\n### Result and edge cases\n\n- **Month-end maturities** produce month-end previous-coupon dates: a 31 August maturity at\n  `frequency` 2 gives 28 or 29 February, not the 28th of some other month.\n- **Early settlements** are accepted; the schedule extends backwards past any plausible issue\n  date, and when the coupon before settlement falls before 1900 Excel returns 0 (FN-COUPNUM-001).\n- **`settlement` ≥ `maturity`** is a documented error, so the function never returns `maturity`\n  itself as a previous coupon date.\n- Empty, missing and error arguments follow the shared call model.\n\n\n\n### Errors\n\n\nDocumented on Microsoft's Learn page for this function, in these words (it says \"generates an\nerror\" without naming a worksheet error value):\n\n| Condition (documented) | Documented outcome |\n|---|---|\n| `settlement` or `maturity` is not a valid date | error |\n| `frequency` is any number other than 1, 2 or 4 | error |\n| `basis` < 0 or `basis` > 4 | error |\n| `settlement` ≥ `maturity` | error |\n\n",
    "sources": "- Microsoft Learn, **WorksheetFunction.CoupPcd method (Excel)** —\n  <https://learn.microsoft.com/en-us/office/vba/api/excel.worksheetfunction.couppcd>. Source of\n  the parameter table, the five-row basis table, the `Double` return type, the \"All arguments\n  are truncated to integers\" rule, the date-entry warning, and the four error conditions. This\n  page carries **no description sentence**, which is recorded above as a documentation finding.\n- Handbook, [COUPNCD](FUNC.COUPNCD.md#the-coupon-schedule) — the shared schedule construction.\n- Handbook evidence record `EV-FIN-0030` — what the six `COUP*` figures are, and are not.\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\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| 20131 | Windows, bitness not recorded, AMD Ryzen 7 4800H with Radeon Graphics | 1,060 |\n| 20430 | Windows, 64-bit, AMD Ryzen 7 4800H with Radeon Graphics | 3,012 |\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.COUPPCD.json).",
    "what-it-does": "\n`COUPPCD(settlement, maturity, frequency, [basis])` returns **the coupon date on or before the\nsettlement date** — the start of the current coupon period — as an Excel date serial.\n\nIt is the mirror of [COUPNCD](FUNC.COUPNCD.md), and the two together bracket the period that\n[COUPDAYBS](FUNC.COUPDAYBS.md), [COUPDAYSNC](FUNC.COUPDAYSNC.md) and\n[COUPDAYS](FUNC.COUPDAYS.md) measure. The schedule it selects from is described once, on\n[COUPNCD](FUNC.COUPNCD.md#the-coupon-schedule): coupon dates run backwards from `maturity` in\nsteps of `12/frequency` months, with month-end anchoring, and there is no issue date to stop\nthem.\n\n**The previous coupon date is notional, not historical.** The schedule is generated from\n`maturity` alone, so `COUPPCD` will happily return a date before the security existed. That is\nthe intended behaviour for accrual arithmetic on a seasoned bond, and it is a trap for anyone\nusing the function to ask \"when was the last coupon actually paid\".\n\n### A documentation gap worth recording\n\n*The quoted one-line description is Microsoft's text, from its support article <https://support.microsoft.com/en-us/office/couppcd-function-2eb50473-6ee9-4052-a206-77a9a385d5b3>.*\n\n\n### Arguments\n\n\n`COUPPCD(settlement, maturity, frequency, [basis])` — the family's shared four arguments, with\nMicrosoft's wording quoted on [COUPDAYBS](FUNC.COUPDAYBS.md#arguments).\n\n| Argument | Meaning | Required? |\n|---|---|---|\n| `settlement` | The security's settlement date. | Required |\n| `maturity` | The security's maturity date. | Required |\n| `frequency` | Coupon payments per year: 1, 2 or 4. | Required |\n| `basis` | The day-count basis, 0–4. | Optional, defaults to 0 |\n\nThe standard five-row basis table is documented on this page — 0 or omitted = US (NASD) 30/360,\n1 = actual/actual, 2 = actual/360, 3 = actual/365, 4 = European 30/360.\n\n**`basis` cannot change the answer.** A coupon date is a calendar date; no day-count convention\nmoves it. `basis` is nevertheless validated, so an out-of-range value converts a well-defined\ndate into an error. The same non-participating-but-fatal argument appears on\n[COUPNCD](FUNC.COUPNCD.md) and [COUPNUM](FUNC.COUPNUM.md).\n\nMicrosoft documents that **\"All arguments are truncated to integers.\"** Dates should be produced\nby `DATE` or by other formulas rather than typed as text; ordinary coercion rules are in\n[Coercion and lifting](../model/02-coercion-and-lifting.md).\n\n\n"
  },
  "signature": {
    "display": "COUPPCD(settlement, maturity, frequency, [basis])",
    "parameters": [
      {
        "description": null,
        "name": "settlement",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "maturity",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "frequency",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "basis",
        "optional": true,
        "repeats": false
      }
    ],
    "trailing_repeats": false
  },
  "sources": {
    "metadata": {
      "admission": {
        "label": "implemented",
        "reason": null
      },
      "arity": {
        "max": 4,
        "min": 3
      },
      "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": "Last coupon date on or before the settlement date",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Returns the previous coupon date before the settlement date",
        "microsoft_url": "https://support.microsoft.com/en-us/office/couppcd-function-2eb50473-6ee9-4052-a206-77a9a385d5b3"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "COUPPCD"
        },
        {
          "locale": "bg-BG",
          "name": "COUPPCD"
        },
        {
          "locale": "cs-CZ",
          "name": "COUPPCD"
        },
        {
          "locale": "da-DK",
          "name": "KUPONDAG.FORRIGE"
        },
        {
          "locale": "de-DE",
          "name": "COUPPCD"
        },
        {
          "locale": "el-GR",
          "name": "COUPPCD"
        },
        {
          "locale": "en-AU",
          "name": "COUPPCD"
        },
        {
          "locale": "en-GB",
          "name": "COUPPCD"
        },
        {
          "locale": "en-US",
          "name": "COUPPCD"
        },
        {
          "locale": "es-ES",
          "name": "CUPON.FECHA.L1"
        },
        {
          "locale": "et-EE",
          "name": "COUPPCD"
        },
        {
          "locale": "fi-FI",
          "name": "KORKOPÄIVÄ.EDELLINEN"
        },
        {
          "locale": "fr-FR",
          "name": "DATE.COUPON.PREC*"
        },
        {
          "locale": "he-IL",
          "name": "COUPPCD"
        },
        {
          "locale": "hr-HR",
          "name": "COUPPCD"
        },
        {
          "locale": "hu-HU",
          "name": "UTOLSÓ.SZELVÉNYDÁTUM"
        },
        {
          "locale": "id-ID",
          "name": "COUPPCD"
        },
        {
          "locale": "it-IT",
          "name": "COUPPCD"
        },
        {
          "locale": "ja-JP",
          "name": "COUPPCD"
        },
        {
          "locale": "ko-KR",
          "name": "COUPPCD"
        },
        {
          "locale": "lt-LT",
          "name": "COUPPCD"
        },
        {
          "locale": "lv-LV",
          "name": "COUPPCD"
        },
        {
          "locale": "nb-NO",
          "name": "OBLIG.DAG.FORRIGE"
        },
        {
          "locale": "nl-NL",
          "name": "COUP.DATUM.VB"
        },
        {
          "locale": "pl-PL",
          "name": "WYPŁ.DATA.POPRZ"
        },
        {
          "locale": "pt-BR",
          "name": "COUPPCD"
        },
        {
          "locale": "pt-PT",
          "name": "CUPDATAANT"
        },
        {
          "locale": "ro-RO",
          "name": "COUPPCD"
        },
        {
          "locale": "ru-RU",
          "name": "ДАТАКУПОНДО"
        },
        {
          "locale": "sk-SK",
          "name": "COUPPCD"
        },
        {
          "locale": "sl-SI",
          "name": "COUPPCD"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "COUPPCD"
        },
        {
          "locale": "sv-SE",
          "name": "KUPFKD"
        },
        {
          "locale": "th-TH",
          "name": "COUPPCD"
        },
        {
          "locale": "tr-TR",
          "name": "KUPONGÜNÖKT işlevi"
        },
        {
          "locale": "uk-UA",
          "name": "COUPPCD"
        },
        {
          "locale": "vi-VN",
          "name": "COUPPCD"
        },
        {
          "locale": "zh-CN",
          "name": "COUPPCD"
        },
        {
          "locale": "zh-HK",
          "name": "COUPPCD"
        },
        {
          "locale": "zh-TW",
          "name": "COUPPCD"
        }
      ],
      "signature": {
        "display": "COUPPCD(settlement, maturity, frequency, [basis])",
        "parameters": [
          {
            "description": null,
            "name": "settlement",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "maturity",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "frequency",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "basis",
            "optional": true,
            "repeats": false
          }
        ],
        "trailing_repeats": false
      },
      "surface_name": "COUPPCD",
      "version_marker": null,
      "xlcall": {
        "code": "457",
        "symbol": "xlfCouppcd"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/couppcd-function-2eb50473-6ee9-4052-a206-77a9a385d5b3"
  },
  "try_it": {
    "formula": "=COUPPCD(44043, 2958465, 2, 1)"
  },
  "url": "https://handbook.dnacalc.com/functions/COUPPCD.html",
  "variants": [],
  "versions": [
    {
      "behaviour": "COUPPCD(44043, 2958465, 2, 1) returned 44012 (0x40e57d8000000000). Inputs were supplied through cells using Value2. These are controls from this environment, not a same-input comparison with another build.",
      "excel_build": "16.0 build 20430",
      "observations": [
        {
          "call": "COUPPCD(44043, 2958465, 2, 1)",
          "excel": {
            "bits": "0x40e57d8000000000",
            "display": "44012",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "settlement",
              "value": {
                "bits": "0x40e5816000000000",
                "display": "44043",
                "kind": "number"
              }
            },
            {
              "name": "maturity",
              "value": {
                "bits": "0x4146924080000000",
                "display": "2958465",
                "kind": "number"
              }
            },
            {
              "name": "frequency",
              "value": {
                "bits": "0x4000000000000000",
                "display": "2",
                "kind": "number"
              }
            },
            {
              "name": "basis",
              "value": {
                "bits": "0x3ff0000000000000",
                "display": "1",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20430, Windows 64-bit, AMD Ryzen 7 4800H"
        }
      ],
      "platform": "Windows 64-bit, AMD Ryzen 7 4800H",
      "sources": [
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/3345a87/content/notes/FN-COUPDAYS-001.json"
      ]
    },
    {
      "behaviour": "=COUPPCD(A1,400,2,0) returned 0 (0x0000000000000000). Inputs were supplied through cells using Value2. These are controls from this environment, not a same-input comparison with another build.",
      "excel_build": "16.0.20527.20088",
      "observations": [
        {
          "call": "=COUPPCD(A1,400,2,0)",
          "excel": {
            "bits": "0x0000000000000000",
            "display": "0",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "A1",
              "value": {
                "bits": "0x0000000000000000",
                "display": "0",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0.20527.20088 Current Channel, Windows 64-bit (NT 10.0.26200), x86-64, AMD Ryzen 7 4800H, en-ZA"
        }
      ],
      "platform": "Windows 64-bit (NT 10.0.26200), x86-64, AMD Ryzen 7 4800H, en-ZA",
      "sources": [
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/3345a87/content/notes/FN-COUPNUM-001.json"
      ]
    },
    {
      "behaviour": "1,060 captured inputs are indexed for this environment. Capture dates: 2026-07-19 to 2026-07-19. This is a reading count, not a comparison with another build.",
      "excel_build": "16.0 build 20131",
      "platform": "Windows, bitness not recorded, AMD Ryzen 7 4800H with Radeon Graphics",
      "sources": [
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.COUPPCD.json"
      ]
    },
    {
      "behaviour": "3,012 captured inputs are indexed for this environment. Capture dates: 2026-09-24 to 2026-09-25. This is a reading count, not a comparison with another build.",
      "excel_build": "16.0 build 20430",
      "platform": "Windows, 64-bit, AMD Ryzen 7 4800H with Radeon Graphics",
      "sources": [
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.COUPPCD.json"
      ]
    }
  ]
}