OpenBI Docs Buy

Time.StartOfHour

The start of the hour a time falls in: the minutes and seconds set to zero.

Group: Dates and times. Power Query M has it too: a query that uses it is written as in Power BI.

Syntax

Time.StartOfHour(dateTime as any) as any
ParameterTypeDescription
dateTimeanyA time, datetime or datetimezone value; null gives null.

Returns

any. The same kind of value, on the whole hour; a date comes back as it is.

Remarks

  • A datetimezone keeps its offset: the hour is its own clock's.
  • Handy for counting orders or readings per hour: group by the hour's start.

Examples

The hour an order came in

Time.StartOfHour(#datetime(2024, 3, 15, 14, 37, 12))
#datetime(2024, 3, 15, 14, 0, 0)

A shift's first hour

Time.StartOfHour(#time(9, 45, 0))
#time(9, 0, 0)

Orders by hour

let
    Orders = #table(type table [Order = text, Placed = datetime], {{"A-101", #datetime(2024, 3, 15, 9, 5, 0)}, {"A-102", #datetime(2024, 3, 15, 9, 50, 0)}, {"A-103", #datetime(2024, 3, 15, 10, 15, 0)}})
in
    Table.Group(Table.AddColumn(Orders, "Hour", each Time.StartOfHour([Placed]), type datetime), {"Hour"}, {{"Orders", Table.RowCount, Int64.Type}})
HourOrders
2024-03-15 09:00:002
2024-03-15 10:00:001

Time.EndOfHour, Date.StartOfDay, Time.Hour.

Last updated · OpenBI Studio 0.3.79