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
| Parameter | Type | Description |
|---|---|---|
text | nullable text | The text to read; null gives null. |
options | any 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.yyyyreads 15.03.2024. The letters are those ofDate.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 nullto 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)
Related functions
Date.From, Date.ToText, DateTime.FromText, Table.TransformColumnTypes.