OpenBI Docs Buy

DateTime.From

Turns a value into a datetime: a date gets midnight, a number counts days and parts of days, text is read.

Group: Dates and times. Power Query M has it too: a query that uses it is written as in Power BI.

Syntax

DateTime.From(value as any, optional culture as nullable text) as nullable datetime
ParameterTypeDescription
valueanyA datetime, date, datetimezone, time, number or text; null gives null.
culturenullable text
optional
A culture's name for reading text; left out, the query's culture.

Returns

nullable datetime. The datetime.

Remarks

  • A number counts days from 30 December 1899, as Excel does for today's dates, with the fraction as the time of day: 45366.75 is 15 March 2024 at 18:00.
  • A time alone is placed on 30 December 1899, day 0 of that count.
  • A datetimezone becomes the computer's local time: 14:30 at -05:00 is 20:30 on a computer in Oslo in winter. The computer's time zone is the one of the computer that runs the query, with its summer time: the studio's on your desk, the server's when a model refreshes there. These examples ran in Oslo (+01:00 in winter, +02:00 in summer).

Examples

A date at midnight

DateTime.From(#date(2024, 3, 15))
#datetime(2024, 3, 15, 0, 0, 0)

An Excel date and time

DateTime.From(45366.75)
#datetime(2024, 3, 15, 18, 0, 0)

Text

DateTime.From("2024-03-15 14:30")
#datetime(2024, 3, 15, 14, 30, 0)

DateTime.FromText, Date.From, DateTimeZone.RemoveZone, Number.From.

Last updated · OpenBI Studio 0.3.79