DateTimeZone.RemoveZone
DateTimeZoneStrips the timezone information from a datetimezone value, returning a datetime.
Syntax
DateTimeZone.RemoveZone(dateTimeZone as nullable datetimezone) as nullable datetimeParameters
| Name | Type | Required | Description |
|---|---|---|---|
dateTimeZone | datetimezone | Yes | The datetimezone value to strip timezone information from. |
Return Value
datetime — A datetime value with the same date and time as the input, but without timezone offset information.
Remarks
DateTimeZone.RemoveZone strips the UTC offset from a datetimezone value and returns a plain datetime with the same date and time components. The time value itself is not adjusted — only the timezone annotation is removed. This is distinct from DateTimeZone.ToUtc, which first converts the time to UTC before returning a datetime.
Use this function when you need a plain datetime for compatibility with functions or data destinations that do not accept datetimezone values. A common scenario is converting DateTimeZone.FixedUtcNow() or DateTimeZone.LocalNow() down to a datetime for use in duration arithmetic or comparison with datetime-typed columns.
If the input is null, the function returns null. When your goal is to normalize all timestamps to UTC before removing the zone, pipe through DateTimeZone.ToUtc first: DateTimeZone.RemoveZone(DateTimeZone.ToUtc(myDTZ)).
Examples
Example 1: Strip timezone from timestamps to produce plain datetimes
#table(
type table [WithZone = datetimezone, WithoutZone = datetime],
{
{#datetimezone(2024, 1, 15, 9, 30, 0, -5, 0), DateTimeZone.RemoveZone(#datetimezone(2024, 1, 15, 9, 30, 0, -5, 0))},
{#datetimezone(2024, 3, 15, 14, 0, 0, 1, 0), DateTimeZone.RemoveZone(#datetimezone(2024, 3, 15, 14, 0, 0, 1, 0))},
{#datetimezone(2024, 6, 1, 9, 0, 0, 5, 30), DateTimeZone.RemoveZone(#datetimezone(2024, 6, 1, 9, 0, 0, 5, 30))}
}
)WithZone | WithoutZone | |
|---|---|---|
| 1 | 1/15/2024 2:30:00 PM | 1/15/2024 9:30:00 AM |
| 2 | 3/15/2024 1:00:00 PM | 3/15/2024 2:00:00 PM |
| 3 | 6/1/2024 3:30:00 AM | 6/1/2024 9:00:00 AM |
Example 2: Remove zone from a specific datetimezone
#table(
type table [WithZone = datetimezone, WithoutZone = datetime],
{{#datetimezone(2024, 3, 15, 14, 30, 0, -5, 0),
DateTimeZone.RemoveZone(#datetimezone(2024, 3, 15, 14, 30, 0, -5, 0))}}
)WithZone | WithoutZone | |
|---|---|---|
| 1 | 3/15/2024 7:30:00 PM | 3/15/2024 2:30:00 PM |
Example 3: Normalize to UTC then remove zone
let
Input = #datetimezone(2024, 3, 15, 9, 0, 0, -5, 0),
AsUTC = DateTimeZone.ToUtc(Input),
AsDatetime = DateTimeZone.RemoveZone(AsUTC)
in
#table(
type table [Original = datetimezone, UTC = datetimezone, UTCDatetime = datetime],
{{Input, AsUTC, AsDatetime}}
)Original | UTC | UTCDatetime | |
|---|---|---|---|
| 1 | 3/15/2024 2:00:00 PM | 3/15/2024 2:00:00 PM | 3/15/2024 2:00:00 PM |