try_to_number

try_to_number

try_to_number 介绍

try_to_number(expr, fmt) - 根据字符串格式fmt将字符串expr转换为数字。如果字符串expr与预期格式不匹配,则返回NULL。该格式遵循与to_number函数相同的语义。

Examples:

> SELECT try_to_number('454', '999');
 454
> SELECT try_to_number('454.00', '000.00');
 454.00
> SELECT try_to_number('12,454', '99,999');
 12454
> SELECT try_to_number('$78.12', '$99.99');
 78.12
> SELECT try_to_number('12,454.8-', '99,999.9S');
 -12454.8

Since: 3.3.0