DateTime.From
Creates a datetime from the given value.
Syntax
DateTime.From(
value as any,
optional culture as text
) as datetime
Remarks
Returns a datetime
value from the given value
. An optional culture
may also be provided (for example, "en-US").If the given value
is null
, DateTime.From
returns null
. If the given value
is datetime
, value
is returned. Values of the following types can be converted to a datetime
value:
text
: Adatetime
value from textual representation. Refer toDateTime.FromText
for details.date
: Adatetime
withvalue
as the date component and12:00:00 AM
as the time component.datetimezone
: The localdatetime
equivalent ofvalue
.time
: Adatetime
with the date equivalent of the OLE Automation Date of0
as the date component andvalue
as the time component.number
: Adatetime
equivalent of the OLE Automation Date expressed byvalue
.
value
is of any other type, an error is returned.
Examples
Example #1
Convert <code>#time(06, 45, 12)</code> to a <code>datetime</code> value.
DateTime.From(#time(06, 45, 12))
Result:
#datetime(1899, 12, 30, 06, 45, 12)
Example #2
Convert <code>#date(1975, 4, 4)</code> to a <code>datetime</code> value.
DateTime.From(#date(1975, 4, 4))
Result:
#datetime(1975, 4, 4, 0, 0, 0)
Category
DateTime