DateTime.From

DateTime.From is a Power Query M function that returns a datetime value from the given value, with optional culture specification. It can convert text, date, datetimezone, time, and number types to a datetime value.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

DateTime.From(
   value as any,
   optional culture as nullable text,
) as nullable datetime
ArgumentAttributeDescription
valueThe value to extract a datetime value from.
cultureoptionalThe culture argument enables the specification of a Culture code (e.g., “nl-NL” or “en-US”) to align transformations with local formatting conventions. If this argument is omitted, functions default to Culture.Current, which reflects the system’s regional settings.

Description

Returns a datetime value from the given value. An optional culture may also be provided (for example, “en-US”). If the given value is nullDateTime.From returns null. If the given value is datetimevalue is returned. Values of the following types can be converted to a datetime value:

  • text: A datetime value from textual representation. Refer to DateTime.FromText for details.
  • date: A datetime with value as the date component and 12:00:00 AM as the time component.
  • datetimezone: The local datetime equivalent of value.
  • time: A datetime with the date equivalent of the OLE Automation Date of 0 as the date component and value as the time component.
  • number: A datetime equivalent of the OLE Automation Date expressed by value.

If value is of any other type, an error is returned.

Examples

Convert #time( 06, 45, 12 ) to a datetime value.

// Output: #datetime( 1899, 12, 30, 06, 45, 12 )
DateTime.From( #time( 06, 45, 12 ) )

Convert #date( 1975, 4, 4 ) to a datetime value.

// Output: #datetime( 1975, 4, 4, 0, 0, 0 )
DateTime.From( #date( 1975, 4, 4 ) )

Other functions related to DateTime.From are:

BI Gorilla Youtube Channel

Last update: August 25, 2023 | Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/datetime-from
© 2023 BI Gorilla. All rights reserved. Content derived from Microsoft documentation is property of Microsoft Corp.