Time.ToRecord

Time

Converts a time value to a record containing its parts.

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

Syntax

Time.ToRecord(time as time) as record

Parameters

NameTypeRequiredDescription
timetimeYesThe time value to convert to a record.

Return Value

recordA record with Hour, Minute, and Second fields.

Remarks

Time.ToRecord converts a time value into a record with the fields Hour, Minute, and Second. Each field contains the corresponding numeric component from the time value.

Examples

Example 1: Convert an OrderLog time to a record

let
    FirstRow = Table.First(OrderLog),
    TimeValue = DateTime.Time(FirstRow[Timestamp]),
    Rec = Time.ToRecord(TimeValue)
in
    #table(
        type table [Hour = number, Minute = number, Second = number],
        {{Rec[Hour], Rec[Minute], Rec[Second]}}
    )
Result
Hour
Minute
Second
19300

Example 2: Convert a scalar time to a record

let
    Rec = Time.ToRecord(#time(14, 30, 45))
in
    #table(
        type table [Hour = number, Minute = number, Second = number],
        {{Rec[Hour], Rec[Minute], Rec[Second]}}
    )
Result
Hour
Minute
Second
1143045

Compatibility

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