Time.ToText
Writes a time of day as text, in the culture's short form or a format you give.
Group: Dates and times. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
Time.ToText(time as nullable time, optional options as any, optional culture as nullable text) as nullable text
| Parameter | Type | Description |
|---|---|---|
time | nullable time | The time to write; null gives null. |
options | any optional | A record [Format = ..., Culture = ...], both fields optional; or, as older queries do, a format as text. |
culture | nullable text optional | A culture's name, when options is a format given as text. |
Returns
nullable text. The time as text.
Remarks
- Text follows the culture: the one given, else the query's (
Culture.Current), which is the model's Locale for import, else the model's own culture, else en-US. These examples run in en-US unless a culture is given. Left without a format, en-US writes 2:30 PM, without seconds; nb-NO writes 14:30. - The letters of a format are those of
DateTime.ToText:HH:mm:ssfor a 24-hour clock with seconds.
Examples
The culture's short form
Time.ToText(#time(14, 30, 0))
"2:30 PM"
A 24-hour clock
Time.ToText(#time(14, 30, 0), [Format = "HH:mm"])
"14:30"
In Norwegian
Time.ToText(#time(14, 30, 0), [Culture = "nb-NO"])
"14:30"