DateTime.FromText
This function creates a date and time value from a text representation provided as input. Optionally, additional properties can be specified using a record parameter named options. The options record ...
This function creates a date and time value from a text representation provided as input. Optionally, additional properties can be specified using a record parameter named options. The options record can include the following fields:
- Format: A text value that specifies the format to be used for parsing the date and time. More information on valid format values can be found at https://go.microsoft.com/fwlink/?linkid=2180104 and https://go.microsoft.com/fwlink/?linkid=2180105. If the Format field is omitted or set to null, the date will be parsed using a best effort method.
- Culture: When the Format field is not null, the Culture field controls certain format specifiers. For example, in "en-US", "MMM" represents months as "Jan", "Feb", "Mar", etc., while in "ru-RU", "MMM" represents months as "янв", "фев", "мар", etc. If the Format field is null, the Culture field specifies the default format to be used. If Culture is null or not provided, the Culture.Current setting will be used.
For backward compatibility
Example 1
Transformation of the string "2010-12-31T01:30:00" into a date and time value.
Instructions
In Power Query M language, use the function MDateTime.FromText("2010-12-31T01:30:25").
Result
The output will be #datetime(2010, 12, 31, 1, 30, 25).
Example 2
Conversion of "2010-12-31T01:30:00.121212" into a date and time value.
Instructions
With Power Query M, utilize the MDateTime.FromText("30 Dez 2010 02:04:50.369730", [Format="dd MMM yyyy HH:mm:ss.ffffff", Culture="de-DE"]).
Result
The result will be #datetime(2010, 12, 30, 2, 4, 50.36973).
Example 3
Changing "2010-12-31T01:30:00" into a datetime format.
Instructions
Use Power Query MDateTime.FromText("2000-02-08T03:45:12Z", [Format="yyyy-MM-dd'T'HH:mm:ss'Z'", Culture="en-US"]).
Result
The result will be #datetime(2000, 2, 8, 3, 45, 12).
Example 4
Converting "20101231T013000" into a datetime value.
Instructions
To accomplish this, run Power Query MDateTime.FromText("20101231T013000", [Format="yyyyMMdd'T'HHmmss", Culture="en-US"]).
Result
The output w