PARSE_CURRENCY
Last updated
Was this helpful?
Last updated
Was this helpful?
The function PARSE_CURRENCY takes a string and returns a currency.
This function parses a from a such as "$1.00". If the input string cannot be parsed into a Currency, PARSE_CURRENCY will return a Currency of zero U.S. dollars and a precision of two, See for more details.
currency_string (required, type: string) A string representing a currency.
locale (optional, type: string, default: "en-US") The locale to use when parsing a currency symbol. For example, the string "$1.00" will be parsed as one U.S. dollar given a locale of "en-US", but will be parsed as one Canadian dollar when given a locale of **"en-CA".**Locale must match a valid .
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.
By default, when the locale parameter is omitted, the currency will be parsed using a locale of "en-US".
With a locale of "en-CA", the dollar sign will be interpreted as Canadian dollars rather than U.S. dollars.
If there is no currency symbol in the input string, U.S. dollars will be assumed.
Regardless of the locale provided, the Euro symbol (€) will always be interpreted as Euros. The locale will be used only for disambiguation.
If a currency cannot be parsed, PARSE_CURRENCY will return a value of zero U.S. dollars.
This is true regardless of the provided locale.
The PARSE_CURRENCY function is the logical opposite of the function. In most cases, formatting, and then parsing a 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.