OpenBI Docs Buy

Date.From

Turns a value into a date: a datetime loses its time, a number counts 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

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

Returns

nullable date. The date.

Remarks

  • A number counts days from 30 December 1899, day 0, as Excel does for today's dates: 1 is 31 December 1899, 45366 is 15 March 2024. Any fraction (the time of day) is dropped.
  • Text is read as Date.FromText reads it.
  • A datetimezone is first moved to the computer's time zone, and its date there is the answer: 23:30 in New York is already the next day in Oslo. 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).

Compared with Power Query

Known difference in OpenBI Studio 0.3.79, found while this page was written and run on its engine:

  • (try Date.From("5. maaliskuuta", "fi-FI"))[HasError]: Power Query gives true: in fi-FI it can't read the day and month ("5. maaliskuuta", 5 March) that the culture's own month-and-day form writes. OpenBI reads it as 5 March of this year and gives false.

Examples

The date of a datetime

Date.From(#datetime(2024, 3, 15, 14, 30, 0))
#date(2024, 3, 15)

An Excel serial number

Date.From(45366)
#date(2024, 3, 15)

Dates written as text, en-US

List.Transform({"2024-03-15", "3/15/2024"}, Date.From)
{#date(2024, 3, 15), #date(2024, 3, 15)}

Date.FromText, DateTime.Date, DateTime.From, Number.From.

Last updated · OpenBI Studio 0.3.79