Date.FromText
Creates a Date from local, universal, and custom Date formats.
Syntax
Date.FromText(
text as text,
optional options as any
) as date
Remarks
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: Atextvalue indicating the format to use. For more details, go to https://go.microsoft.com/fwlink/?linkid=2180104 and https://go.microsoft.com/fwlink/?linkid=2180105. Omitting this field or providingnullwill result in parsing the date using a best effort.Culture: WhenFormatis not null,Culturecontrols some format specifiers. For example, in"en-US""MMM"is"Jan", "Feb", "Mar", ..., while in"ru-RU""MMM"is"янв", "фев", "мар", .... WhenFormatisnull,Culturecontrols the default format to use. WhenCultureisnullor omitted,Culture.Currentis used.
options may also be a text value. This has the same behavior as if options = [Format = null, Culture = options].
Examples
Example #1
Convert <code>"2010-12-31"</code> into a <code>date</code> value.
Date.FromText("2010-12-31")
Result:
#date(2010, 12, 31)
Example #2
Convert using a custom format and the German culture.
Date.FromText("30 Dez 2010", [Format="dd MMM yyyy", Culture="de-DE"])
Result:
#date(2010, 12, 30)
Example #3
Find the date in the Gregorian calendar that corresponds to the beginning of 1400 in the Hijri calendar.
Date.FromText("1400", [Format="yyyy", Culture="ar-SA"])
Result:
#date(1979, 11, 20)
Category
Date