Number.From
Creates a number from the given value.
Syntax
Number.From(
value as any,
optional culture as text
) as number
Remarks
Returns a number value from the given value. An optional culture may also be provided (for example, "en-US").If the given value is null, Number.From returns null. If the given value is number, value is returned. Values of the following types can be converted to a number value:
text: Anumbervalue from textual representation. Common text formats are handled ("15", "3,423.10", "5.0E-10"). Refer toNumber.FromTextfor details.logical: 1 fortrue, 0 forfalse.datetime: A double-precision floating-point number that contains an OLE Automation date equivalent.datetimezone: A double-precision floating-point number that contains an OLE Automation date equivalent of the local date and time ofvalue.date: A double-precision floating-point number that contains an OLE Automation date equivalent.time: Expressed in fractional days.duration: Expressed in whole and fractional days.
value is of any other type, an error is returned.
Examples
Example #1
Get the <code>number</code> value of <code>"4"</code>.
Number.From("4")
Result:
4
Example #2
Get the <code>number</code> value of <code>#datetime(2020, 3, 20, 6, 0, 0)</code>.
Number.From(#datetime(2020, 3, 20, 6, 0, 0))
Result:
43910.25
Example #3
Get the <code>number</code> value of <code>"12.3%"</code>.
Number.From("12.3%")
Result:
0.123
Category
Number.Conversion and formatting