DateTime.AddZone

Updated on

DateTime.AddZone is a Power Query M function that adds timezone information to the date(time) value, including timezoneHours and optionally timezoneMinutes.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

DateTime.AddZone(
   dateTime as nullable datetime,
   timezoneHours as number,
   optional timezoneMinutes as nullable number,
) as nullable datetimezone

Description

DateTime.AddZone adds timezone information to the dateTime argument, which can be of type datetime. The function includes timezoneHours and, optionally, timezoneMinutes, specifying the desired offset from UTC time. This allows for precise adjustments to the datetime value to reflect a specific timezone.

Examples

Set the timezone to UTC+7:30 ( 7 hours and 30 minutes past UTC ).

// Output: #datetimezone( 2010, 12, 31, 11, 56, 2, 7, 30 )
DateTime.AddZone( #datetime( 2010, 12, 31, 11, 56, 02 ), 7, 30 )

Other functions related to DateTime.AddZone are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/datetime-addzone