DateTimeZone.ZoneHours Function in Power Query
The DateTimeZone.ZoneHours function in Power Query returns the timezone hour component of a datetimezone value.
Syntax
DateTimeZone.ZoneHours(dateTimeZone as nullable datetimezone) as nullable number
The function has the following parameter:
- dateTimeZone: A datetimezone value from which the time zone hour component is extracted. If dateTimeZone is null, the function returns null.
Example: Let’s get the time zone hours component from the datetimezone value.
Power Query M
let
// Step 1: Create a table with datetimezone values
Source = Table.FromRecords({
[Name = "Ashish", CreatedAt = #datetimezone(2025, 4, 10, 8, 30, 0, 3, 30)],
[Name = "Ravi", CreatedAt = #datetimezone(2025, 4, 10, 12, 45, 0, 5, 30)],
[Name = "Neha", CreatedAt = #datetimezone(2025, 4, 10, 14, 0, 0, 2, 0)]
}),
// Step 2: Get the Timezone hours from DateTimeZone value
ZoneRemoved = Table.AddColumn(Source, "TransformedOutput", each DateTimeZone.ZoneHours([CreatedAt]))
in
ZoneRemoved The output of the above code is shown in the image below:
