PARSE_NUMBER
Last updated
Was this helpful?
Last updated
Was this helpful?
The function PARSE_NUMBER converts a string containing numeric digits into a number.
This function accepts a and parses any numeric digits into a . If a Number cannot be parsed from the String, then zero is returned. Any non-numeric characters in the String are ignored.
string_containing_a_number (required, type: string) The string to parse the number from.
parsed_number (type: number) The resulting number.
Although capable of much more, when given a string that contains a number, PARSE_NUMBER will return the number.
The PARSE_NUMBER function will ignore additional characters between numbers such as thousandths
The PARSE_NUMBER function will interpret a period character ('.') as separating the decimal portion of the number.
We saw earlier that the PARSE_NUMBER function will ignore thousandths separators, it will in fact, ignore any non-numeric character.
When PARSE_NUMBER is given a string that does not contain a number, it returns zero.
When encountering a numeric character that can no longer be a part of a number, PARSE_NUMBER will omit any digits from the rest of the String.
This allows parsing numbers that may include additional text, for example, the period at the end of the first sentence stops the number parsing in this example.
Another difference is that the PARSE_NUMBER function is locale un-aware. If a number has been formatted with a European locale that uses periods for thousandths groupings, and commas to separate the decimal, the PARSE_NUMBER will return an incorrectly interpret the first period as a decimal separator.
Unlike other parsing functions, while the PARSE_NUMBER function is spiritually the opposite of the function, this relation is not exact. For example, the PARSE_NUMBER function cannot parse exponential notation that the FORMAT_NUMBER function generates.