Date.ToText Function in Power Query
The Date.ToText function in Power Query (M language) converts a date, datetime, or datetimezone value into a text string, optionally using a custom format and culture.
Syntax
Date.ToText( dateTime as any, optional format as nullable text, optional culture as nullable text ) as nullable text
The function has the following parameters:
- dateTime: The value to convert (type
date
,datetime
, ordatetimezone
). - optional format: A text string specifying the output format. If not provided, the default format for the current locale is used. Examples:
- "dd-MM-yyyy"
- "yyyy/MM/dd HH:mm:ss"
- "MMM dd, yyyy"
- optional culture: A text value indicating the culture name (e.g., "en-US", "fr-FR") used for localization of month and day names.
Example: Convert #date(2025, 8, 24)
into a text value.
Power Query M
let Source = Date.ToText(#date(2025, 8, 24)) in Source
The output of the above code is:
"24-08-2025"
Note: Result output may vary depending on system locale.
Example: Custom format.
Power Query M
let Source = Date.ToText(#date(2025, 8, 24), "yyyy-MM-dd") in Source
The output of the above code is:
"2025-08-24"
Example: Custom format.
Power Query M
let Source = Date.ToText(#date(2025, 8, 24), "dddd, dd/MM/yyyy") in Source
The output of the above code is:
"Sunday, 24-08-2025"