Date.FromText
Syntax
Date.FromText(text as nullable text, optional options as any) as nullable date
About
Creates a date
value from a textual representation, text
. An optional record
parameter, options
, may be provided to specify additional properties. The record
can contain the following fields:
Format
: Atext
value indicating the format to use. For more details, go to Standard date and time format strings and Custom date and time format strings. Omitting this field or providingnull
will result in parsing the date using a best effort.Culture
: WhenFormat
is not null,Culture
controls some format specifiers. For example, in"en-US"
"MMM"
is"Jan", "Feb", "Mar", ...
, while in"ru-RU"
"MMM"
is"янв", "фев", "мар", ...
. WhenFormat
isnull
,Culture
controls the default format to use. WhenCulture
isnull
or omitted, Culture.Current is used.
To support legacy workflows, options
may also be a text value. This has the same behavior as if options = [Format = null, Culture = options]
.
Example 1
Convert "2010-12-31"
into a date
value.
Usage
Date.FromText("2010-12-31")
Output
#date(2010, 12, 31)
Example 2
Convert using a custom format and the German culture.
Usage
Date.FromText("30 Dez 2010", [Format="dd MMM yyyy", Culture="de-DE"])
Output
#date(2010, 12, 30)
Example 3
Find the date in the Gregorian calendar that corresponds to the beginning of 1400 in the Hijri calendar.
Usage
Date.FromText("1400", [Format="yyyy", Culture="ar-SA"])
Output
#date(1979, 11, 20)