List.DateTimes
ListGenerates a list of datetime values starting from a given datetime, with a specified count and step duration.
Syntax
List.DateTimes(start as datetime, count as number, step as duration) as listParameters
| Name | Type | Required | Description |
|---|---|---|---|
start | datetime | Yes | The starting datetime value. |
count | number | Yes | The number of datetime values to generate. |
step | duration | Yes | The duration to add between each successive datetime. |
Return Value
list — A list of datetime values of length count, beginning at start and incrementing by step.
Remarks
List.DateTimes generates a sequence of datetime values, useful for creating time-series scaffolding, generating hourly or sub-hourly intervals, or building datetime-based lookup lists for reporting.
The step parameter uses the #duration(days, hours, minutes, seconds) literal. For hourly intervals use #duration(0, 1, 0, 0), for 15-minute intervals use #duration(0, 0, 15, 0). Unlike calendar-month steps, duration-based steps are exact and will not drift. A count of 0 returns an empty list.
Choose between the related sequence functions based on what your data requires: use List.Dates when you only need date values (no time component), List.DateTimes for date-and-time without timezone, and List.DateTimeZones when timezone offset information must be preserved. Converting the result to a table using Table.FromList with a single-column splitter is the standard way to build a datetime dimension.
Examples
Example 1: Generate hourly datetimes for a day
List.DateTimes(#datetime(2024, 1, 1, 0, 0, 0), 24, #duration(0, 1, 0, 0))Result | |
|---|---|
| 1 | 1/1/2024 12:00:00 AM |
| 2 | 1/1/2024 1:00:00 AM |
| 3 | 1/1/2024 2:00:00 AM |
| 4 | ... |
Example 2: Generate 15-minute intervals
List.DateTimes(#datetime(2024, 3, 15, 8, 0, 0), 8, #duration(0, 0, 15, 0))Result | |
|---|---|
| 1 | 3/15/2024 8:00:00 AM |
| 2 | 3/15/2024 8:15:00 AM |
| 3 | 3/15/2024 8:30:00 AM |
| 4 | 3/15/2024 8:45:00 AM |
| 5 | 3/15/2024 9:00:00 AM |
| 6 | 3/15/2024 9:15:00 AM |
| 7 | 3/15/2024 9:30:00 AM |
| 8 | 3/15/2024 9:45:00 AM |
Example 3: Create a datetime table for a week at noon
let
DateTimes = List.DateTimes(#datetime(2024, 1, 1, 12, 0, 0), 7, #duration(1, 0, 0, 0)),
AsTable = Table.FromList(DateTimes, Splitter.SplitByNothing(), {"DateTime"})
in
AsTableThe final output — converts the datetime list into a single-column table with each value in its own row.
DateTime | |
|---|---|
| 1 | 1/1/2024 12:00:00 PM |
| 2 | 1/2/2024 12:00:00 PM |
| 3 | 1/3/2024 12:00:00 PM |
| 4 | ... |