DateTimeZone.From
DateTimeZoneConverts a value to a datetimezone.
Syntax
DateTimeZone.From(value as any, optional culture as nullable text) as nullable datetimezoneParameters
| Name | Type | Required | Description |
|---|---|---|---|
value | any | Yes | The value to convert. Accepts text, date, datetime, and number values. |
culture | text | No | Culture code for locale-specific parsing (e.g., "en-US"). |
Return Value
datetimezone — A 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 | |
|---|---|---|---|
| 1 | L001 | 1/15/2024 9:30:00 AM | 1/15/2024 9:30:00 AM |
| 2 | L002 | 1/16/2024 2:15:00 PM | 1/16/2024 2:15:00 PM |
| 3 | L003 | 1/18/2024 11:00:00 AM | 1/18/2024 11:00:00 AM |
| 4 | L004 | 1/20/2024 8:45:00 AM | 1/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 | |
|---|---|
| 1 | 3/15/2024 7:30:00 PM |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks