#datetimezone

Updated on

#datetimezone is a Power Query M function that creates a datetimezone value from numbers representing the year, month, day, hour, minute, (fractional) second, (fractional) offset-hours, and offset-minutes.

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

Syntax

#datetimezone(
   year as number,
   month as number,
   day as number,
   hour as number,
   minute as number,
   second as number,
   offsetHours as number,
   offsetMinutes as number,
) as datetimezone

Description

Creates a datetimezone value from numbers representing the year, month, day, hour, minute, (fractional) second, (fractional) offset-hours, and offset-minutes. Raises an error if these conditions are not true:

  • 1 ≤ year ≤ 9999
  • 1 ≤ month ≤ 12
  • 1 ≤ day ≤ 31
  • 0 ≤ hour ≤ 23
  • 0 ≤ minute ≤ 59
  • 0 ≤ second < 60
  • -14 ≤ offset-hours + offset-minutes / 60 ≤ 14

Examples

Returns the datetimezone value of June 10, 2023 (date) 04:08:12 (time) -01:30 (offset).

#datetimezone( 2023, 6, 10, 4, 8, 12, -1, 30 ) // Returns 10/06/2023 04:08:12 -01:30

You can easily extract the zonehours, zoneminutes, or turn the value into a different format.

DateTimeZone.ZoneHours(   #datetimezone( 2023, 6, 10, 4, 8, 12, -1, -30 ) ) // Returns - 1

DateTimeZone.ZoneMinutes( #datetimezone( 2023, 6, 10, 4, 8, 12, -1, -30 ) ) // Returns - 30

DateTimeZone.RemoveZone(  #datetimezone( 2023, 6, 10, 4, 8, 12, -1, -30 ) ) // Returns 10/06/2023 04:08:12

DateTimeZone.ToUtc( #datetimezone( 2023, 6, 10, 4, 8, 12, -1, -30 ) ) // Returns 10/06/2023 05:38:12 +00:00

Other functions related to #datetimezone are:

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