DateTime.ToText
Returns a textual representation of the datetime value.
Syntax
DateTime.ToText(
dateTime as datetime,
optional options as any,
optional culture as text
) as text
Remarks
Returns a textual representation of dateTime. An optional record parameter, options, may be provided to specify additional properties. culture is only used for legacy workflows. The record can contain the following fields:
Format: Atextvalue indicating the format to use. For more details, go to https://go.microsoft.com/fwlink/?linkid=2180104 and https://go.microsoft.com/fwlink/?linkid=2180105. Omitting this field or providingnullwill result in formatting the date using the default defined byCulture.Culture: WhenFormatis not null,Culturecontrols some format specifiers. For example, in"en-US""MMM"is"Jan", "Feb", "Mar", ..., while in"ru-RU""MMM"is"янв", "фев", "мар", .... WhenFormatisnull,Culturecontrols the default format to use. WhenCultureisnullor omitted,Culture.Currentis used.
options and culture may also be text values. This has the same behavior as if options = [Format = options, Culture = culture].
Examples
Example #1
Convert <code>#datetime(2010, 12, 31, 01, 30, 25)</code> into a <code>text</code> value. <i>Result output may vary depending on current culture.</i>
DateTime.ToText(#datetime(2010, 12, 31, 01, 30, 25))
Result:
"12/31/2010 1:30:25 AM"
Example #2
Convert using a custom format and the German culture.
DateTime.ToText(#datetime(2010, 12, 30, 2, 4, 50.36973), [Format="dd MMM yyyy HH:mm:ss.ffffff", Culture="de-DE"])
Result:
"30 Dez 2010 02:04:50.369730"
Example #3
Convert using the ISO 8601 pattern.
DateTime.ToText(#datetime(2000, 2, 8, 3, 45, 12),[Format="yyyy-MM-dd'T'HH:mm:ss'Z'", Culture="en-US"])
Result:
"2000-02-08T03:45:12Z"
Category
DateTime