# PARSE_CURRENCY

Chandra Bergmann

### Return Values

currency (type: currency)
A Currency with an amount/code that is parsed from currency_string, and an appropriate precision for the world currency that was parsed.

### Examples

By default, when the locale parameter is omitted, the currency will be parsed using a locale of "en-US".
PARSE_CURRENCY("$1.00") -> { amount: 100, code: "USD", precision: 2} With a locale of "en-CA", the dollar sign will be interpreted as Canadian dollars rather than U.S. dollars. PARSE_CURRENCY("$1.00", "CAD") -> {  amount: 100,  code: "CAD",  precision: 2}

If there is no currency symbol in the input string, U.S. dollars will be assumed.

PARSE_CURRENCY("1.00", "CAD") -> {  amount: 100,  code: "USD",  precision: 2}

Regardless of the locale provided, the Euro symbol () will always be interpreted as Euros. The locale will be used only for disambiguation.

PARSE_CURRENCY("€1.00") -> {   amount: 100,  code: "EUR",  precision: 2}PARSE_CURRENCY("€1.00", "en-CA") -> {   amount: 100,  code: "EUR",  precision: 2}

If a currency cannot be parsed, PARSE_CURRENCY will return a value of zero U.S. dollars.

PARSE_CURRENCY("Not a currency") -> {   amount: 0,  code: "USD",  precision: 2}

This is true regardless of the provided locale.

PARSE_CURRENCY("Not a currency", "en-CA") -> {  amount: 0,  code: "USD",  precision: 2}

### Discussion

The PARSE_CURRENCY function is the logical opposite of the FORMAT_CURRENCY function. In most cases, formatting, and then parsing a Currency will return the original value. However, when there is ambiguity as to which world currency a symbol refers to, this may not be the case. For example, formatting, and then parsing Canadian dollars with a locale of "en-US" will return a Currency in U.S. dollars.

PARSE_CURRENCY(FORMAT_CURRENCY(CURRENCY(100, "CAD"))) -> {  amount: 100,  code: "USD",  precision: 2}