Duration.FromText
Reads a length of time from text such as 2.04:30:00 (2 days, 4 hours 30 minutes).
Group: Dates and times. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
Duration.FromText(text as nullable text) as nullable duration
| Parameter | Type | Description |
|---|---|---|
text | nullable text | The text to read; null gives null. |
Returns
nullable duration. The duration; an error when the text cannot be read.
Remarks
- The days and the seconds may be left out: "2.04:30:00", "04:30:00" and "04:30" are all read. Seconds may have a fraction after a point; a leading minus makes the duration negative.
- A lone number is a number of days: "45" is 45 days. The ISO 8601 form is read too, such as P1DT2H for a day and two hours. An empty text gives null.
- It is the form
Duration.ToTextwrites, so the two make a round trip.
Examples
Two days and four and a half hours
Duration.FromText("2.04:30:00")
#duration(2, 4, 30, 0)
Hours and minutes only
Duration.FromText("00:45")
#duration(0, 0, 45, 0)
An ISO 8601 duration
Duration.FromText("P1DT2H")
#duration(1, 2, 0, 0)