<!-- https://learnsql.cpetoday.com/functions/m/duration-from -->
# Duration.From

Language: Power Query M
Category: Duration
Syntax: Duration.From(value as any) as nullable duration
Summary: Converts a number to a duration, where the number is read as days.
Returns: The duration, or null when the input is null.
Level: Intermediate
Related: Duration.Days, Duration.TotalDays, Duration.TotalHours, Duration.Hours, Date.AddDays

## What it does
Duration.From turns a plain number into a duration. A number is read as days, so 2 becomes two days. Source systems often store a lead time, a term or a delay as a plain number of days, and Duration.From gives that number the duration type, so the other duration functions can be used on it.
## Syntax and arguments
- value: a number of days, or a value that can be read as a duration.
## Example
A supplier scorecard holds each supplier's quoted lead time as a number of days. The purchasing team converts the lead time into hours, which their service level report uses.

```powerquery
let
    Suppliers = #table(type table [Supplier = text, LeadDays = number],
        {{"Acme Supply Co", 2}, {"Blue Harbor LLC", 5}}),
    AsDuration = Table.AddColumn(Suppliers, "LeadTime", each Duration.From([LeadDays]), type duration),
    Hours = Table.AddColumn(AsDuration, "LeadHours", each Duration.TotalHours([LeadTime]), type number)
in
    Hours
```

Two days is 48 hours, and five days is 120 hours. The scorecard can now compare the lead times with the hours each supplier actually took.
## Example: a second, different use
Use a days value from an ERP export as a duration, then take its whole days with Duration.Days to check the value.
## Things to watch
- A plain number is read as days. A number of hours must be divided by 24 first, or built with a full duration.
- A decimal number gives a fraction of a day, which is handled by Duration.TotalDays and Duration.TotalHours.
- A duration is not a date. To move a date by a number of days, use Date.AddDays.
- Null in gives null out.
## In business terms
Lead times, payment terms and cycle times often arrive from source systems as plain numbers. Converting them to durations lets the report work on them with the same rules as dates, so the scorecard and the contract use the same definitions.
