Date.ToText
DateConverts a date value to a text string.
Syntax
Date.ToText(date as nullable date, optional options as any) as nullable textParameters
| Name | Type | Required | Description |
|---|---|---|---|
date | date | Yes | The date value to convert to text. |
options | any | No | A record or culture text string. Supported record fields: Format (custom format string, e.g., "dd/MM/yyyy") and Culture (e.g., "en-US"). |
Return Value
text — A text representation of the date, or null if the input is null.
Remarks
Date.ToText formats a date value as a text string. Without options, it produces an ISO 8601-style string (e.g., "2024-03-15"). Use the Format field in the options record to apply custom patterns such as "dd/MM/yyyy" or "MMMM d, yyyy". The Culture field controls locale-specific formatting (e.g., month names and day-of-week names). Format strings follow .NET custom date format conventions.
Always specify Culture when using locale-sensitive format specifiers like MMMM (full month name) or dddd (full day name) to ensure consistent output across environments. Without an explicit Culture, the result depends on the host machine's locale.
If the input is null, the function returns null. For formatting datetime values, use DateTime.ToText instead, which handles both date and time components.
Examples
Example 1: Format order dates as long-form text
Table.AddColumn(
Table.SelectColumns(
Table.FirstN(Sales, 4),
{"OrderID", "OrderDate"}
),
"OrderDateText",
each Date.ToText([OrderDate], [Format="MMMM d, yyyy", Culture="en-US"]),
type text
)OrderID | OrderDate | OrderDateText | |
|---|---|---|---|
| 1 | 1 | 1/15/2024 | January 15, 2024 |
| 2 | 2 | 1/18/2024 | January 18, 2024 |
| 3 | 3 | 2/1/2024 | February 1, 2024 |
| 4 | 4 | 2/10/2024 | February 10, 2024 |
Example 2: Format a date in UK style
#table(
type table [Date = date, Formatted = text],
{{#date(2024, 3, 15), Date.ToText(#date(2024, 3, 15), [Format="dd/MM/yyyy", Culture="en-GB"])}}
)Date | Formatted | |
|---|---|---|
| 1 | 3/15/2024 | 15/03/2024 |
Example 3: Format as abbreviated month and year
Table.AddColumn(
Table.SelectColumns(Table.FirstN(Sales, 5), {"OrderID", "OrderDate"}),
"PeriodLabel",
each Date.ToText([OrderDate], [Format="MMM yyyy", Culture="en-US"]),
type text
)OrderID | OrderDate | PeriodLabel | |
|---|---|---|---|
| 1 | 1 | 1/15/2024 | Jan 2024 |
| 2 | 2 | 1/18/2024 | Jan 2024 |
| 3 | 3 | 2/1/2024 | Feb 2024 |
| 4 | 4 | 2/10/2024 | Feb 2024 |
| 5 | 5 | 3/5/2024 | Mar 2024 |