Downloads
Power Query MDateBeginner

Date.ToText

Formats a date as text using a format string, such as "yyyy-MM-dd" or "MMM yyyy".

Syntax
Date.ToText(date as nullable date, optional format as nullable text, optional culture as nullable text) as nullable text

Returns: The formatted text, or null when the input is null.

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

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.

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

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.

Related functions

All Power Query M functions · View as Markdown · M basics