Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Power Query Date.ToText: Step-by-Step Guide

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Date.ToText converts a date value into a text string in Power Query, and the quickest working call is . The second argument is a format string, and if you leave it out Power Query uses a default format that may not match what you need. This guide shows how to add the function in the Power Query Editor, how to choose a format that survives a load into Excel or Power BI, and how to fix the usual errors.

What You'll Need

  • A Power Query query that already contains a column of Date type values (or a column you can convert to Date).
  • Access to the Power Query Editor, either from Excel (Data > Get Data) or from Power BI Desktop (Transform data).
  • A basic idea of the output format you want, for example yyyy-MM-dd for ISO-style dates or dd/MM/yyyy for UK-style dates.

Step-by-Step

  1. Open your query in the Power Query Editor. In Excel, go to Data > Get Data > Launch Power Query Editor. In Power BI Desktop, use Home > Transform data. Menu labels can differ slightly by version, device and region.
  2. Check the data type of the column you want to convert. The column header should show a calendar icon. If it shows ABC or a number icon, right-click the header, choose Change Type, and pick Date. Date.ToText expects a date value, not text that looks like a date.
  3. Add a custom column. On the Add Column tab, click Custom Column. Give it a name such as DateText.
  4. In the formula box, enter the call with your column name and a format string, for example Date.ToText([OrderDate], "yyyy-MM-dd"). Column names with spaces need square brackets and the exact spelling, such as [Order Date].
  5. Click OK. Power Query adds the new column and shows the converted text values.
  6. Set the new column's data type to Text. Right-click the new column header and choose Change Type > Text. This prevents Power Query from reinterpreting the result as a date when the query loads.
  7. Rename the column if needed, then close and load the query. In Excel use Home > Close & Load; in Power BI use Home > Close & Apply.

If you prefer not to add a column, you can transform the existing one in place: right-click the date column header, choose Transform > Date Only or use the formula bar to replace the step with Date.ToText([OrderDate], "yyyy-MM-dd"). Keep a duplicate of the original column if you still need the true date for sorting or relationships.

Common Mistakes

  • Passing text instead of a date. If the column is type Text, Date.ToText returns an error. Convert the column to Date first, or use Date.FromText on the text before calling Date.ToText.
  • Using the wrong format codes. In Power Query format strings, MM is month and mm is minutes. Mixing them up produces unexpected values. Use yyyy for a four-digit year, MM for a two-digit month and dd for a two-digit day.
  • Forgetting the second argument. Date.ToText([OrderDate]) works but uses a default format tied to the query's culture settings, which can differ between machines. Always supply an explicit format when the output feeds another system.
  • Leaving the result as Date type. If the new column stays typed as Date, Power Query may convert your text back into a date on load. Set the column type to Text.
  • Assuming the output is a real date. After conversion the value is text, so date arithmetic and date hierarchies no longer apply. Keep a separate date column if you need those.

Tips

  • Use yyyy-MM-dd when the text will be read by databases, APIs or other software, because it sorts correctly as text.
  • Use dd/MM/yyyy or MM/dd/yyyy only when a human audience expects that layout, and state the convention in the column name.
  • You can embed literal text in the format string, for example Date.ToText([OrderDate], "dd MMM yyyy") for outputs like 05 Jan 2025.
  • Apply the same format consistently across every query that feeds the same report, so text dates compare correctly when merged.
  • If you need the month name in a specific language, set the query's locale rather than relying on the machine default.

Troubleshooting

If the custom column shows Error, click the error cell to read the message. A message about converting to type Date usually means the source column is text or contains blanks; filter out nulls or convert the column first. A message about the format string means a code is invalid for Date.ToText, so check for stray characters or a code meant for a different function.

If the values look right in the editor but wrong after loading, confirm the column type is Text and that Excel or Power BI has not applied a date format to it. In Excel, select the loaded column and check the number format; in Power BI, check the column's data category and format in the model view.

If the format string is ignored, make sure you are calling Date.ToText and not Date.FromText, and that the second argument is a quoted string. If the query fails only on refresh, the source data may contain a value that is not a valid date; add a step that removes errors or replaces them with null.

If you cannot find the Custom Column button, you may be in the wrong tab; it sits on the Add Column tab in current versions. If the option is greyed out, the query may be connected in DirectQuery mode where some transformations are limited.

Frequently Asked Questions

What is the difference between Date.ToText and Text.From?

Date.ToText lets you specify a format string and is intended for date values. Text.From converts many types to text but gives you less control over the date layout.

Can I convert a date to text without adding a new column?

Yes. You can replace the existing step in the formula bar or use Transform options on the column, but keep a copy of the original date if you still need it for calculations.

Why does my output show minutes instead of months?

Format codes are case-sensitive. Use MM for month and mm for minutes in Power Query format strings.

Does Date.ToText work in Power BI and Excel alike?

Yes, both use the same Power Query engine, so the function and format strings behave the same way in each host.

How do I get a month name in another language?

Set the locale for the query or use a culture argument where the function supports it, rather than relying on the computer's regional settings.

Can I convert a column that contains blanks?

Yes, but blanks become null in the text column. Filter or replace nulls first if the downstream system cannot accept them.