#datetimezone

DateTimeZone

Creates a datetimezone value from date, time, and UTC offset components.

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

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

Parameters

NameTypeRequiredDescription
yearnumberYesThe year component (e.g. 2024).
monthnumberYesThe month component (1–12).
daynumberYesThe day component (1–31, depending on month).
hournumberYesThe hour component (0–23).
minutenumberYesThe minute component (0–59).
secondnumberYesThe second component (0–59, can include fractional seconds).
offsetHoursnumberYesThe UTC offset in hours (e.g. -5 for UTC-5, 0 for UTC).
offsetMinutesnumberYesThe UTC offset minutes component (typically 0 or 30).

Return Value

datetimezoneA datetimezone value representing the specified date and time with UTC offset.

Remarks

#datetimezone is M's literal constructor for creating datetimezone values — a datetime paired with an explicit UTC offset. This is the only M type that can unambiguously represent a specific instant in time.

The offset is expressed as a pair of integers (offsetHours, offsetMinutes). UTC is represented as 0, 0. UTC-5 is -5, 0. UTC+5:30 (India Standard Time) is 5, 30.

Use DateTimeZone.RemoveZone to strip the offset and get a plain datetime. Use DateTimeZone.ToUtc to convert to UTC. In Power BI Service and scheduled dataflow refreshes, DateTimeZone.LocalNow() returns UTC — not your local machine's time — so prefer #datetimezone or UTC-aware functions for scheduling logic.

Examples

Example 1: Create a datetimezone literal (UTC-5)

#datetimezone(2024, 3, 15, 14, 30, 0, -5, 0)
Result
Result
13/15/2024 7:30:00 PM

Example 2: Convert to UTC

DateTimeZone.ToUtc(#datetimezone(2024, 3, 15, 14, 30, 0, -5, 0))
Result
Result
13/15/2024 7:30:00 PM

Example 3: Remove the timezone offset

DateTimeZone.RemoveZone(#datetimezone(2024, 3, 15, 14, 30, 0, -5, 0))
Result
Result
13/15/2024 2:30:00 PM

Compatibility

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