#datetimezone
DateTimeZoneCreates a datetimezone value from date, time, and UTC offset components.
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 datetimezoneParameters
| Name | Type | Required | Description |
|---|---|---|---|
year | number | Yes | The year component (e.g. 2024). |
month | number | Yes | The month component (1–12). |
day | number | Yes | The day component (1–31, depending on month). |
hour | number | Yes | The hour component (0–23). |
minute | number | Yes | The minute component (0–59). |
second | number | Yes | The second component (0–59, can include fractional seconds). |
offsetHours | number | Yes | The UTC offset in hours (e.g. -5 for UTC-5, 0 for UTC). |
offsetMinutes | number | Yes | The UTC offset minutes component (typically 0 or 30). |
Return Value
datetimezone — A 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 | |
|---|---|
| 1 | 3/15/2024 7:30:00 PM |
Example 2: Convert to UTC
DateTimeZone.ToUtc(#datetimezone(2024, 3, 15, 14, 30, 0, -5, 0))Result | |
|---|---|
| 1 | 3/15/2024 7:30:00 PM |
Example 3: Remove the timezone offset
DateTimeZone.RemoveZone(#datetimezone(2024, 3, 15, 14, 30, 0, -5, 0))Result | |
|---|---|
| 1 | 3/15/2024 2:30:00 PM |