<!-- https://learnsql.cpetoday.com/functions/m/date-totext -->
# Date.ToText

Language: Power Query M
Category: Date
Syntax: Date.ToText(date as nullable date, optional format as nullable text, optional culture as nullable text) as nullable text
Summary: Formats a date as text using a format string, such as "yyyy-MM-dd" or "MMM yyyy".
Returns: The formatted text, or null when the input is null.
Level: Beginner
Related: Date.MonthName, Date.DayOfWeekName, DateTime.ToText, Text.From, Text.Format

## What it does
Date.ToText turns a date into text in a layout you choose. It is used for file names that carry a date, for period keys such as "2026-10", and for labels in a report. The format string controls the layout, and the culture controls the language and the separators of the names.
## Syntax and arguments
- date: the date to format.
- format (optional): a format string. "yyyy-MM-dd" gives 2026-10-29. "yyyy-MM" gives a period key. "MMM yyyy" gives an abbreviated month and year.
- culture (optional): the culture for names and separators, such as "en-US".
## Example
An export file is named with the period it covers, and a period key is built for a lookup table, so both use the same format.

```powerquery
let
    PeriodEnd = #date(2026, 10, 29),
    FileName = "gl_export_" & Date.ToText(PeriodEnd, "yyyy-MM-dd", "en-US") & ".csv",
    PeriodKey = Date.ToText(PeriodEnd, "yyyy-MM", "en-US"),
    Label = Date.ToText(PeriodEnd, "MMM yyyy", "en-US")
in
    {FileName, PeriodKey, Label}
```

The file name is "gl_export_2026-10-29.csv", the period key is "2026-10" and the label is "Oct 2026". The period key sorts correctly as text, which is why the year comes first.
## Example: a second, different use
Build a date text in the form "29 October 2026" for a letter, with the month name in full, using a format such as "d MMMM yyyy".
## Things to watch
- The format letters are case sensitive. MM is the month and mm is the minute, so mix them up and the output is wrong.
- Without a format, the default layout depends on the machine's culture.
- The result is text. Keep the date column for any date arithmetic.
- Null in gives null out.
## In business terms
File names, period keys and report labels carry dates as text. A fixed format keeps the file names consistent for the people and systems that pick them up each month.
