List.Times
ListGenerates a list of time values starting from a given time, with a specified count and step duration.
Syntax
List.Times(start as time, count as number, step as duration) as listParameters
| Name | Type | Required | Description |
|---|---|---|---|
start | time | Yes | The starting time value. |
count | number | Yes | The number of time values to generate. |
step | duration | Yes | The duration to add between each successive time value. |
Return Value
list — A list of time values of length count, beginning at start and incrementing by step.
Remarks
List.Times generates a sequence of time values representing times of day (hours, minutes, seconds) without a date component. It is useful for building appointment slot lists, time-of-day dimension tables, or scheduling grids.
The step parameter uses the #duration(days, hours, minutes, seconds) syntax. For 30-minute slots use #duration(0, 0, 30, 0); for 1-hour slots use #duration(0, 1, 0, 0). If the generated time exceeds 23:59:59, it wraps around — for example, #time(23, 0, 0) with a 2-hour step produces 23:00:00 then 1:00:00.
A count of 0 returns an empty list. Use List.DateTimes when a full date-and-time value is needed. To convert the resulting list to a table for use as a dimension, use Table.FromList with Splitter.SplitByNothing() and a single column name.
Examples
Example 1: Generate hourly time slots starting at midnight
List.Times(#time(0, 0, 0), 8, #duration(0, 1, 0, 0))Result | |
|---|---|
| 1 | 0:00:00 |
| 2 | 1:00:00 |
| 3 | 2:00:00 |
| 4 | 3:00:00 |
| 5 | 4:00:00 |
| 6 | 5:00:00 |
| 7 | 6:00:00 |
| 8 | 7:00:00 |
Example 2: Generate 30-minute appointment slots
List.Times(#time(9, 0, 0), 8, #duration(0, 0, 30, 0))Result | |
|---|---|
| 1 | 9:00:00 |
| 2 | 9:30:00 |
| 3 | 10:00:00 |
| 4 | 10:30:00 |
| 5 | 11:00:00 |
| 6 | 11:30:00 |
| 7 | 12:00:00 |
| 8 | 12:30:00 |
Example 3: Create a time-of-day dimension table
let
Times = List.Times(#time(0, 0, 0), 24, #duration(0, 1, 0, 0)),
TimeTable = Table.FromList(Times, Splitter.SplitByNothing(), {"Hour"})
in
TimeTableThe final output — a 24-row table with one Hour column listing each hour of the day from 0:00:00 to 23:00:00.
Hour | |
|---|---|
| 1 | 0:00:00 |
| 2 | 1:00:00 |
| 3 | 2:00:00 |
| 4 | ... |