# Currency Amount (Trailing Negative)

Key: `finance.currency.amount_neg_trailing`

Currency amount with trailing minus sign or CR/DR suffix for negative values. Standard in SAP, COBOL/mainframe exports, and bank statement formats. The negative indicator follows the amount.

Page: <https://meridian.online/docs/finetype/types/finance/currency/amount_neg_trailing>

Samples: `$1,234.56-`, `1,234.56 CR`, `$999.99-`, `10,000.00 DR`

## Use it

Shell

```shell
finetype infer -i '$1,234.56-' --mode column
# → finance.currency.amount_neg_trailing
```

DuckDB

```sql
SELECT ft_infer('$1,234.56-');
-- → 'finance.currency.amount_neg_trailing'
```

Cast template: {col} is your column

```sql
CAST(CASE WHEN {col} LIKE '%-' OR {col} LIKE '%CR' THEN '-' || REGEXP_REPLACE(REGEXP_REPLACE(REGEXP_REPLACE({col}, '[-]$|\s*(CR|DR)$', ''), '[\$€£¥₹]', ''), ',', '', 'g') ELSE REGEXP_REPLACE(REGEXP_REPLACE(REGEXP_REPLACE({col}, '[-]$|\s*(CR|DR)$', ''), '[\$€£¥₹]', ''), ',', '', 'g') END AS DECIMAL(18,2))
```

## Background

### Origin

Micro Focus's COBOL documentation allows only one of the editing sign control symbols in a given PICTURE character-string.[[1]](https://www.microfocus.com/documentation/reuze/60d/lhpdf40g.htm) Micro Focus's COBOL documentation says that when CR or DB is used, the symbols must represent the rightmost character positions counted in the size of the item.[[1]](https://www.microfocus.com/documentation/reuze/60d/lhpdf40g.htm) In Micro Focus's table of editing symbols, a - in the picture prints a space when the data item is positive or zero and a minus sign when it is negative.[[1]](https://www.microfocus.com/documentation/reuze/60d/lhpdf40g.htm) Micro Focus's table shows the CR symbol printing as two spaces for a positive or zero item and as CR for a negative one.[[1]](https://www.microfocus.com/documentation/reuze/60d/lhpdf40g.htm)

### Use

SAP's ABAP Programming documentation for the WRITE statement shows a negative packed number output as 1,234,567.89-, with the minus sign after the digits.[[2]](https://help.sap.com/saphelp_46c/helpdata/EN/9f/db9e2335c111d1829f0000e829fbfe/content.htm) Oracle Database's MI number format element returns a negative value with a trailing minus sign and a positive value with a trailing blank.[[3]](https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/Format-Models.html) Oracle Database allows the MI format element only in the last position of a number format model.[[3]](https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/Format-Models.html) PostgreSQL's documentation shows to\_char(-485, '999MI') producing '485-' and to\_char(485, '999MI') producing '485 ' with a trailing space.[[4]](https://www.postgresql.org/docs/current/functions-formatting.html)

PostgreSQL's documentation gives to\_number('12,454.8-', '99G999D9S') as returning -12454.8.[[4]](https://www.postgresql.org/docs/current/functions-formatting.html) Microsoft's Text Import Wizard for Excel has an Advanced option to specify that one or more numeric values may contain a trailing minus sign.[[5]](https://support.microsoft.com/en-us/excel/text-import-wizard) Treat a trailing minus as part of the number rather than stray punctuation, and check that a column's count of negative values is the same before and after you convert it. (Meridian's view)

## Sources

1. [The PICTURE Clause](https://www.microfocus.com/documentation/reuze/60d/lhpdf40g.htm) — documentation
2. [The WRITE Statement](https://help.sap.com/saphelp_46c/helpdata/EN/9f/db9e2335c111d1829f0000e829fbfe/content.htm) — documentation
3. [Format Models](https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/Format-Models.html) — documentation
4. [PostgreSQL: Documentation: 18: 9.8. Data Type Formatting Functions](https://www.postgresql.org/docs/current/functions-formatting.html) — documentation
5. [Text Import Wizard](https://support.microsoft.com/en-us/excel/text-import-wizard) — documentation

## How it's detected

SAP, COBOL/mainframe, bank statements. CR = credit (negative in expense context), DR = debit.
