DateTime.ToText

The function returns a text representation of the dateTime input. An optional parameter, options, can be included to specify additional properties. The culture parameter is only utilized for older wor...

Syntax

DateTime.ToText(dateTime as nullable datetime, optional options as any, optional culture as nullable text) as nullable text

About

The function returns a text representation of the dateTime input. An optional parameter, options, can be included to specify additional properties. The culture parameter is only utilized for older workflows. The options parameter can include the following fields: Format: A text value that specifies the format to be applied. More detailed information can be found at 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 formatted using the default defined by the culture setting. Culture: When the Format field is not null, the Culture setting influences certain format specifications. For instance, in "en-US" "MMM" represents "Jan", "Feb", "Mar", etc., while in "ru-RU" "MMM" stands for "янв", "фев", "мар", etc. If the Format field is null, Culture determines the default format to be used. If Culture is null or not provided, Culture.Current will be used. In order to accommodate older workflows, options and cul

Explanation

To convert the date and time value of 2010, 12, 31, 01, 30, 25 into a text format in Power Query, the function MDateTime.ToText(#datetime(2010, 12, 31, 01, 30, 25)) can be used. The output will be "12/31/2010 1:30:25 AM", however, this may vary depending on the current culture. For a custom format conversion using the German culture, the function would be MDateTime.ToText(#datetime(2010, 12, 30, 2, 4, 50.36973), [Format="dd MMM yyyy HH:mm:ss.ffffff", Culture="de-DE"]). The output in this case will be "30 Dez 2010 02:04:50.369730". When converting using the ISO 8601 pattern, the function is MDateTime.ToText(#datetime(2000, 2, 8, 3, 45, 12),[Format="yyyy-MM-dd'T'HH:mm:ss'Z'", Culture="en-US"]). The output for this conversion will be "2000-02-08T03:45:12Z".