OpenBI Docs Buy

#datetime

Makes a datetime, a date with a time of day and no time zone, from six numbers.

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

Syntax

#datetime(year as number, month as number, day as number, hour as number, minute as number, second as number) as datetime
ParameterTypeDescription
yearnumberThe year, 1 to 9999.
monthnumberThe month, 1 to 12.
daynumberThe day of the month.
hournumberThe hour, 0 to 23.
minutenumberThe minute, 0 to 59.
secondnumberThe second, 0 up to (not including) 60; it may have a fraction.

Returns

datetime. The moment; an error when the numbers are not a valid date and time.

Remarks

  • Year, month, day, hour and minute are whole numbers; the second may carry a fraction, kept to a ten millionth of a second.
  • Subtracting one datetime from another gives a duration; adding a duration to a datetime gives a datetime.

Examples

When an order was placed

#datetime(2024, 3, 15, 14, 30, 0)
#datetime(2024, 3, 15, 14, 30, 0)

A fraction of a second

#datetime(2024, 3, 15, 14, 30, 12.5)
#datetime(2024, 3, 15, 14, 30, 12.5)

Hours worked on a shift

#datetime(2024, 3, 15, 17, 0, 0) - #datetime(2024, 3, 15, 8, 30, 0)
#duration(0, 8, 30, 0)

The difference of two datetimes is a duration: 8 hours and 30 minutes.

#date, #time, #datetimezone, DateTime.From, DateTime.FromText.

Last updated · OpenBI Studio 0.3.79