The Duration.From function in Power Query turns a number or a piece of text into a duration. A number is read as days, so 1.75 becomes 1 day and 18 hours, and text like “3.08:15:00” becomes 3 days, 8 hours, and 15 minutes.
You’ll need it whenever durations reach Power Query as plain numbers or text. Below, I’ll go through seven examples, including adding a turnaround time to a date, converting hours, filtering by length, billing for time, and catching entries that won’t convert.
Follow along with the example file
Duration.From Function Examples.xlsx
In the example file, every example is a query you can open from the Queries & Connections pane. Examples 1 and 2 don’t use a table, so they have no worksheet.
Duration.From Function Syntax
= Duration.From(value as any) as nullable duration
- value – the value you want to turn into a duration. A number is read as a number of days, including any fraction of a day. Text follows the days.hours:minutes:seconds pattern (like 2.05:30:00), with hours from 0 to 23. You can leave out the days or the seconds, and a whole number on its own is read as days.
What it returns – a duration. If the value is null, you get null back, and if it’s already a duration, you get the same duration back.
A value of any other type, such as a date, a time, or TRUE/FALSE, gives an error.
I’ve tested the Duration.From function in Power Query in Excel for Microsoft 365. It’s also part of the Power Query M language that Power BI uses.
When to Use the Duration.From Function
Use this function when you need to:
- Turn a number of days, like 1.5 or 2.25, into a duration
- Add a fractional number of days to a datetime
- Convert hours or minutes stored as decimal numbers into durations
- Read durations exported as text, like 0:52:40 or 1.02:15:00
- Compare a text duration against a limit, such as longer than 45 minutes
- Convert a duration to hours or days for a calculation
- Find duration entries that can’t be converted, without the query failing
Example 1: Convert a Number of Days to a Duration
Let’s start with a single number, so you can see how the function reads it.
Say you have the number 1.75 and you want it as a duration. Create a new blank query (Data > Get Data > From Other Sources > Blank Query) and use this formula in the formula bar:
= Duration.From(1.75)
Result: 1.18:00:00

Here, Duration.From treats 1.75 as a number of days. The 1 becomes 1 day, and the 0.75 is three quarters of a day, which is 18 hours.
Power Query shows a duration as days.hours:minutes:seconds, so 1.18:00:00 means 1 day, 18 hours, 0 minutes, and 0 seconds.
To go the other way and turn a duration back into a number of days, use the Duration.TotalDays function.
Example 2: Convert Text to a Duration
Durations often come in as text, especially from other systems.
Say you have the text “3.08:15:00” and you want it as a duration. Create a new blank query, as in Example 1, and use this formula:
= Duration.From("3.08:15:00")
Result: 3.08:15:00

Here, the number before the dot is the days, and the rest is hours, minutes, and seconds. So the text becomes a real duration of 3 days, 8 hours, and 15 minutes, which you can add to a date or do math with.
You can leave out the days and the seconds. “1:30” gives you 1 hour and 30 minutes, and “1.18:00” gives you 1 day and 18 hours.
The dot separates the days from the hours, so it’s not a decimal point. “2.5:00:00” is 2 days and 5 hours, and “1.5” gives an error because the hours after the dot need minutes too (1 day and 5 hours is “1.05:00”).
A whole number in quotes, like “45”, is read as 45 days, not 45 minutes.
Things are different when the value is an actual time, such as 9:30 AM in a Time column, and not text. Duration.From won’t take a time value and gives an error that says “We couldn’t convert to Duration.”
To get the time since midnight, subtract midnight from it instead, like #time(9,30,0)-#time(0,0,0), which gives 0.09:30:00.
Example 3: Add a Turnaround Time in Days to a Datetime
You can’t add a plain number to a datetime in Power Query, so this is a job for Duration.From.
Below is an Excel table named PrintJobs with the time each print job was received and its turnaround time in days, and I want the time each job will be ready in a new column.

To follow along, select any cell in the table and go to Data > From Table/Range to open it in the Power Query Editor. If Power Query adds a Changed Type step, use #"Changed Type" in place of Source in the formulas below.
Add a new step (by clicking on the fx icon next to the formula bar) and use this formula:
= Table.AddColumn(Source,"Ready By",each [Received]+Duration.From([#"Turnaround (Days)"]),type datetime)
Result: a Ready By column with 11/3/2026 3:00:00 PM, 11/2/2026 5:00:00 PM, 11/5/2026 2:00:00 PM, 11/4/2026 4:00:00 PM, 11/5/2026 10:00:00 AM, and 11/7/2026 11:00:00 AM

Here, Duration.From turns each turnaround into a duration, so 1.25 becomes 1 day and 6 hours. Adding that to the Received datetime moves it forward, so job J-301, received at 9:00 AM on 11/2/2026, is ready at 3:00 PM the next day.
Without Duration.From, [Received]+[#"Turnaround (Days)"] gives an error that says “We cannot apply operator + to types DateTime and Number.” The Date.AddDays function doesn’t help here either, because it only takes whole days and gives an error for 1.25.
The column name has brackets in it, so it’s written as [#"Turnaround (Days)"] in the formula. The Table.AddColumn function adds the new column, and type datetime sets its data type.
Example 4: Convert Hours to a Duration
This one is easy to get wrong, because Duration.From reads every number as days, even when your numbers are hours.
Below is an Excel table named VolunteerHours with the hours each volunteer worked at an event, and I want the time each person volunteered as a duration in a new column.

Let’s first try the obvious formula. Open the table in the Power Query Editor, as in Example 3, and add a new step with this formula:
= Table.AddColumn(Source,"Time Volunteered",each Duration.From([Hours]),type duration)
Result: a Time Volunteered column with 7.12:00:00, 4.06:00:00, 6.00:00:00, 3.18:00:00, 8.12:00:00, and 5.12:00:00

That’s wrong. Amanda Young worked 7.5 hours, but Duration.From read 7.5 as days and gave her 7 days and 12 hours.
To fix it, divide the hours by 24 first, so the number becomes a fraction of a day. Replace the formula with this one:
= Table.AddColumn(Source,"Time Volunteered",each Duration.From([Hours]/24),type duration)
Result: a Time Volunteered column with 0.07:30:00, 0.04:15:00, 0.06:00:00, 0.03:45:00, 0.08:30:00, and 0.05:30:00

Here, 7.5/24 is 0.3125 of a day, which Duration.From turns into 7 hours and 30 minutes. For minutes, divide by 1440 (the number of minutes in a day) instead.
You might think of #duration(0,[Hours],0,0) for this, since #duration takes hours as its second argument. It only works with whole hours, though, and gives an error that says “The number is out of range of a 32 bit integer value.” for 7.5.
Example 5: Filter Text Durations Longer Than 45 Minutes
Here’s a common one when the durations come from another app as text.
Below is an Excel table named Episodes with the length of each podcast episode, stored as text, and I want to keep only the episodes that are longer than 45 minutes.

Open the table in the Power Query Editor, as in Example 3. Then check the icon in the Length column header, because the formula needs that column to be text.
If Power Query changed it to a time (a clock icon) in a Changed Type step, delete that step, since Duration.From gives an error on a time value. Then add a new step with this formula:
= Table.SelectRows(Source,each Duration.From([Length])>#duration(0,0,45,0))
Result: three episodes, Ep 42 (0:52:40), Ep 43 (1:05:09), and Ep 45 (0:47:03)

Here, Duration.From turns each Length into a duration, and #duration(0,0,45,0) builds a duration of 45 minutes to compare it with. The Table.SelectRows function keeps only the rows where the comparison is true.
The Length column itself stays as text, because the conversion happens only inside the filter. Ep 44, at 0:44:55, misses the cut by 5 seconds.
If you’d rather convert the Length column itself, you can change its type to Duration (click the type icon in the column header) and then filter it. That gives the same three episodes, but the Length column no longer shows the original text.
Example 6: Calculate a Charge From Time Logged as Text
Durations become more useful once you turn them into a number you can multiply.
Below is an Excel table named DesignHours with the time each designer logged on a project, stored as text, and their hourly rate, and I want the amount to bill for each project in a new column.

Two of the entries are longer than a day, so they include the days part. For example, 1.02:15:00 is 1 day, 2 hours, and 15 minutes.
Open the table in the Power Query Editor, as in Example 3, and keep the Time Logged column as text, as in Example 5. Then add a new step with this formula:
= Table.AddColumn(Source,"Amount",each Duration.TotalHours(Duration.From([Time Logged]))*[Hourly Rate],type number)
Result: an Amount column with 210, 1443.75, 213.75, 320, and 1852.5

Here, Duration.From turns the text into a duration, and the Duration.TotalHours function gives the total hours in it as a number. That number is then multiplied by the Hourly Rate.
Connor Tucker logged 1 day, 2 hours, and 15 minutes, which is 26.25 hours. At 55 an hour, that’s 1443.75.
Example 7: Flag Duration Entries That Can’t Be Converted
Typed durations are rarely clean, and one bad entry is enough to give you an error.
Below is an Excel table named RepairLog with the downtime for each machine repair, typed in as text, and I want the downtime as a duration in a new column, plus a column that flags any entry that needs fixing.

If you use Duration.From on its own here, RT-82 and RT-84 show an error that says “We couldn’t parse the Duration literal.” The text “2 hrs” isn’t in a duration format, and “27:30:00” has more than 23 hours, which the hours:minutes:seconds form doesn’t allow.
Open the table in the Power Query Editor, as in Example 3, and keep the Downtime column as text, as in Example 5. Then add a new step with this formula:
= Table.AddColumn(Source,"Downtime Duration",each try Duration.From([Downtime]) otherwise null,type duration)
Rename that step to Added Downtime Duration (right-click it under Applied Steps and choose Rename), because the next formula refers to it by that name. Then add one more step with this formula:
= Table.AddColumn(#"Added Downtime Duration","Entry Check",each if [Downtime Duration]=null then "Fix entry" else "OK",type text)
Result: RT-81, RT-83, and RT-85 get their downtime as a duration and show OK. RT-82 and RT-84 get null and show Fix entry.

Here, try ... otherwise null attempts the conversion and returns null instead of an error when it fails. The second step then flags every null, so the bad entries are easy to find instead of quietly disappearing.
A blank Downtime cell also gets null, so it shows Fix entry too.
To fix an entry, rewrite it in a format Duration.From can read. 27 hours and 30 minutes, for example, is 1.03:30:00, which is 1 day, 3 hours, and 30 minutes.
Other Excel Articles You May Also Like:
- Duration.Hours function
- DateTime.From – Use DateTime.From in Power Query M to convert values to date and time.
- Duration.Days – Use Duration.Days in Power Query M to extract the day component from a duration value.
- Date.From – Use Date.From in Power Query M to turn a datetime, serial number, or text into a clean date value.
- DateTime.FromText – Use DateTime.FromText in Power Query M to convert text to date and time.
- Time.Hour – Use Time.Hour in Power Query M to get the hour from a time or datetime.
- Number.From – Use Number.From in Power Query M to convert values to numbers.
- Date.FromText – Use Date.FromText in Power Query M to convert text into real date values.