DateTimeZone.From

DateTimeZone

Converts a value to a datetimezone.

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

Syntax

DateTimeZone.From(value as any, optional culture as nullable text) as nullable datetimezone

Parameters

NameTypeRequiredDescription
valueanyYesThe value to convert. Accepts text, date, datetime, and number values.
culturetextNoCulture code for locale-specific parsing (e.g., "en-US").

Return Value

datetimezoneA datetimezone value converted from the given input.

Remarks

DateTimeZone.From converts text, date, datetime, or number values into a datetimezone. When converting from a datetime that has no timezone information, the local timezone offset is applied. Text values are parsed according to standard datetime formats with timezone offsets, or the specified culture. If the input is null, the function returns null.

Examples

Example 1: Convert OrderLog Timestamp to datetimezone

Table.AddColumn(
    Table.SelectColumns(
        Table.FirstN(OrderLog, 4),
        {"LogID", "Timestamp"}
    ),
    "TimestampUTC",
    each DateTimeZone.From([Timestamp]),
    type datetimezone
)
Result
LogID
Timestamp
TimestampUTC
1L0011/15/2024 9:30:00 AM1/15/2024 9:30:00 AM
2L0021/16/2024 2:15:00 PM1/16/2024 2:15:00 PM
3L0031/18/2024 11:00:00 AM1/18/2024 11:00:00 AM
4L0041/20/2024 8:45:00 AM1/20/2024 8:45:00 AM

Example 2: Convert a text string with timezone to datetimezone

#table(
    type table [Result = datetimezone],
    {{DateTimeZone.From("2024-03-15T14:30:00-05:00")}}
)
Result
Result
13/15/2024 7:30:00 PM

Compatibility

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