Time.Hour
TimeReturns the hour component from a time, datetime, or datetimezone value.
Syntax
Time.Hour(dateTime as any) as nullable numberParameters
| Name | Type | Required | Description |
|---|---|---|---|
dateTime | any | Yes | The time, datetime, or datetimezone value to extract the hour from. |
Return Value
number — The hour component (0 through 23).
Remarks
Time.Hour returns the hour component as a number from 0 to 23 from a time, datetime, or datetimezone value. If the input is null, the function returns null.
Examples
Example 1: Extract hour from OrderLog Timestamp
Table.AddColumn(
Table.SelectColumns(
Table.FirstN(OrderLog, 5),
{"LogID", "Timestamp"}
),
"Hour", each Time.Hour([Timestamp]), Int64.Type
)Result
LogID | Timestamp | Hour | |
|---|---|---|---|
| 1 | L001 | 1/15/2024 9:30:00 AM | 9 |
| 2 | L002 | 1/16/2024 2:15:00 PM | 14 |
| 3 | L003 | 1/18/2024 11:00:00 AM | 11 |
| 4 | L004 | 1/20/2024 8:45:00 AM | 8 |
| 5 | L005 | 2/1/2024 4:20:00 PM | 16 |
Example 2: Extract hour from a scalar time
#table(
type table [Time = time, Hour = number],
{{#time(14, 30, 0), Time.Hour(#time(14, 30, 0))}}
)Result
Time | Hour | |
|---|---|---|
| 1 | 14:30:00 | 14 |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks