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
The DateTime.ToRecord
function converts a datetime value into a record containing its individual components: year, month, day, hour, minute, and second. This allows for easy access and manipulation of each part of the datetime in subsequent query steps.
Examples
To store the different components of a datetime value into a record, you can apply the DateTime.ToRecord
function on a datetime value. Here’s how you can store each component of the #datetime( 2024, 8, 30, 14, 45, 0 )
value in a record:
// Output: [ Year = 2024, Month = 8, Day = 30, Hour = 14, Minute = 45, Second = 0.225 ]
DateTime.ToRecord( #datetime( 2024, 8, 30, 14, 45, 0.225 ) )
In this example, the function converts the datetime August 30, 2024, 14:45:00
.225 into a record with the following components:
This output makes it easy to access and use individual parts of the datetime separately in subsequent steps of your query.
Related functions
Other functions related to DateTime.ToRecord are:
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy