DateTime.ToRecord

DateTime.ToRecord is a Power Query M function that extracts the parts of a given datetime value as a record. The function returns a record containing the year, month, day, hour, minute, second, and fraction of a second.

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

Syntax

DateTime.ToRecord( dateTime as datetime ) as record

Description

Returns a record containing the parts of the given datetime value, dateTime.

  • dateTime: A datetime value for from which the record of its parts is to be calculated.

Examples

Convert the #datetime( 2011, 12, 31, 11, 56, 2 ) value into a record containing Date and Time values.

DateTime.ToRecord( #datetime( 2011, 12, 31, 11, 56, 2 ) )

 /* Output: 
[
      Year = 2011,
      Month = 12,
      Day = 31,
      Hour = 11,
      Minute = 56,
      Second = 2
]
 */ 

Other functions related to DateTime.ToRecord are:

BI Gorilla Youtube Channel

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