DateTimeZone.FromText
This function creates a datetimezone value based on a provided text representation. An optional parameter, options, can be included to specify additional properties. The options parameter can include ...
DateTimeZone.FromText(text as nullable text, optional options as any) as nullable datetimezone
This function creates a datetimezone value based on a provided text representation. An optional parameter, options, can be included to specify additional properties. The options parameter can include the following fields:
- Format: A text value that specifies the format to be used. Visit the following links for more information: https://go.microsoft.com/fwlink/?linkid=2180104 and https://go.microsoft.com/fwlink/?linkid=2180105. If this 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 determines certain format specifiers. For example, in "en-US" "MMM" represents "Jan", "Feb", "Mar", etc., while in "ru-RU" "MMM" represents "янв", "фев", "мар", etc. If the Format field is null, Culture determines the default format to be used. If Culture is null or not provided, the default Culture.Current value will be used.
For backward compatibility, the options parameter can also be a text value. This will have the same
Example 1
Transform the string "2010-12-31T01:30:00-08:00" into a datetimezone value.
Procedure
Use the Power Query M function DateTimeZone.FromText with the input string "2010-12-31T01:30:00-08:00".
Result
The output will be #datetimezone(2010, 12, 31, 1, 30, 0, -8, 0).
Example 2
Convert the string "30 Dez 2010 02:04:50.369730 +02:00" into a datetimezone value by setting a custom format and using the German culture.
Procedure
Use the Power Query M function DateTimeZone.FromText with the input string "30 Dez 2010 02:04:50.369730 +02:00", format "dd MMM yyyy HH:mm:ss.ffffff zzz", and culture "de-DE".
Result
The output will be #datetimezone(2010, 12, 30, 2, 4, 50.36973, 2, 0).
Example 3
Convert the string "2009-06-15T13:45:30.0000000-07:00" into a datetimezone value following the ISO 8601 format.
Procedure
Use the Power Query M function DateTimeZone.FromText with the input string "2009-06-15T13:45:30.0000000-07:00", format "O", and culture "en-US".
Result
The output will be #datetimezone(2009, 6, 15, 13, 45,