Time.Hour

Time

Returns the hour component from a time, datetime, or datetimezone value.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Time.Hour(dateTime as any) as nullable number

Parameters

NameTypeRequiredDescription
dateTimeanyYesThe time, datetime, or datetimezone value to extract the hour from.

Return Value

numberThe 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
1L0011/15/2024 9:30:00 AM9
2L0021/16/2024 2:15:00 PM14
3L0031/18/2024 11:00:00 AM11
4L0041/20/2024 8:45:00 AM8
5L0052/1/2024 4:20:00 PM16

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
114:30:0014

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks