OpenBI Docs Buy

Date.FromText

Reads a date from text: ISO dates, the culture's own way of writing them, or a format you give.

Group: Dates and times. Power Query M has it too: a query that uses it is written as in Power BI.

Syntax

Date.FromText(text as nullable text, optional options as any) as nullable date
ParameterTypeDescription
textnullable textThe text to read; null gives null.
optionsany
optional
A record [Format = ..., Culture = ...], both fields optional, or a culture's name as text. Left out, the query's culture reads the text.

Returns

nullable date. The date; an error when the text cannot be read as one.

Remarks

  • Without a format, the text is read as the culture writes dates (3/15/2024 in en-US, 05/03/2024 for 5 March in en-GB, 15.03.2024 in nb-NO), and ISO dates (2024-03-15) in every culture. Month names may be the culture's or English.
  • With a format, the text must follow it letter by letter: dd.MM.yyyy reads 15.03.2024. The letters are those of Date.ToText.
  • A two-digit year is read as a year from 1950 to 2049: 99 is 1999, 49 is 2049.
  • Text that cannot be read raises an error; wrap the call in try ... otherwise null to keep the rows that fail as null.

Examples

An ISO date

Date.FromText("2024-03-15")
#date(2024, 3, 15)

A date in a fixed format

Date.FromText("15.03.2024", [Format = "dd.MM.yyyy"])
#date(2024, 3, 15)

A Norwegian month name

Date.FromText("15. mars 2024", [Format = "d. MMMM yyyy", Culture = "nb-NO"])
#date(2024, 3, 15)

Date.From, Date.ToText, DateTime.FromText, Table.TransformColumnTypes.

Last updated · OpenBI Studio 0.3.79