Duration.Days
Date function · By Tahir Nas · Examples run in our simulator · Published · Updated
Returns the days part of a duration.
When to use it
Use it to turn the difference between two dates into a whole number of days, for ages, lead times, days open or overdue counts. Subtracting dates gives a duration value; Duration.Days turns it into a number you can sum, filter or band.
Syntax
Duration.Days(duration as nullable duration) as nullable numberReturns
Whole days.
Example
Duration.Days(#date(2026, 3, 9) - #date(2026, 3, 2))Result
7
Example: days overdue
Subtracting two dates gives a duration; Duration.Days takes its whole days.
Duration.Days(#date(2026, 4, 1) - #date(2026, 3, 15))Result
17
Both results are produced by the Power Query Exercises simulator, an independent implementation of a documented subset of M, and checked on every build.
Good to know
- Date minus date is a duration; null in gives null out.
Common mistakes
- Subtracting text dates.
- Using Duration.Days on datetimes and losing the hours part.
The matching command in Excel
- Excel for Windows
- Add Column > Duration > Days
- What you see
- A new column holds the whole days of the selected duration column.
Paths are for the Power Query editor in Excel for Microsoft 365, checked against Microsoft's documentation on 8 November 2026: Add a column based on a data type (Power Query) (Microsoft Support).
Exercises that use Duration.Days
- intermediate~8 minPro
Calculate days to close each ticket (telecom)
Convert Opened and Closed to dates and compute whole days between them; open tickets stay null.
- intermediate~9 minPro
Build a calendar from the first to the last order date (kite shop)
Create a table with one row for every day from the earliest to the latest order date, including days with no orders.
Learn more
Related functions
Official documentation: Duration.Days on Microsoft Learn.