# Financial functions

> 2 Financial functions in NYXDB: names, aliases, signatures and behaviour.

{/* AUTO-GENERATED from the function catalog. DO NOT EDIT — overwritten on every build. */}

2 functions. Names resolve case-insensitively; an alias binds the same function as its canonical name. Each entry gives the signatures, the behaviour and an example.

| Function | Summary |
| --- | --- |
| [`net_present_value`](#net_present_value) | Discounts regularly spaced cash flows to their combined value at period zero. |
| [`net_present_value_extended`](#net_present_value_extended) | Values irregular dated payments using actual elapsed days and a fixed 365-day year. |

## net_present_value

Discounts regularly spaced cash flows to their combined value at period zero.

```text
net_present_value(rate:float64,values:array(int*|uint*|float32|float64|decimal(P,S))) -> float64
```

| | |
| --- | --- |
| Kind | scalar |
| Signature class | `scalar/binary` |
| Returns | `float64` |
| Streaming | Continuous — evaluated per row with no retained state. |
| Determinism | Deterministic — the same arguments always give the same result. |
| NULL handling | NULL array or rate gives NULL; NULL elements rejected |

Sums values\[t]/(1+rate)^t for consecutive integer periods beginning at t=0, so the first payment is not discounted. A NULL array or rate returns NULL, but a NULL element or rate at or below -1 raises INVALID_ARGUMENT. The result is float64, with NUMERIC_OVERFLOW if checked evaluation cannot produce a finite value.

**Example**

```sql
net_present_value(0.0, [-100, 110])
-- → 10.0
```

## net_present_value_extended

Values irregular dated payments using actual elapsed days and a fixed 365-day year.

```text
net_present_value_extended(rate:float64,values:array(int*|uint*|float32|float64|decimal(P,S)),dates:array(date)) -> float64
```

| | |
| --- | --- |
| Kind | scalar |
| Signature class | `scalar/ternary` |
| Returns | `float64` |
| Streaming | Continuous — evaluated per row with no retained state. |
| Determinism | Deterministic — the same arguments always give the same result. |
| NULL handling | NULL top-level input gives NULL; NULL elements rejected |

Discounts each cash flow by (1+rate) raised to its ACT/365 year fraction from the first supplied date. Value and date arrays must be nonempty, equally sized and free of NULL elements; dates must be nondecreasing and rate greater than -1, otherwise INVALID_ARGUMENT is raised. Top-level NULL inputs produce NULL, while a nonfinite checked result raises NUMERIC_OVERFLOW.

**Example**

```sql
net_present_value_extended(
  0.0,
  [-100,
  110],
  [DATE '2024-01-01',
  DATE '2024-12-31']
)
-- → 10.0
```

---

Source: https://nyxdb.io/docs/functions/financial/
