Date.ToRecord Function in Power Query

The Date.ToRecord function returns a record containing parts of a Date value.

Syntax

Date.ToRecord(date as date) as record

Example:

Power Query M

let
  Source = Table.FromRecords(
    {
      [Year = "20-07-2024"], 
      [Year = "21-07-2024"], 
      [Year = "22-07-2024"], 
      [Year = "23-07-2024"], 
      [Year = "24-07-2024"], 
      [Year = "25-07-2024"], 
      [Year = "26-07-2024"], 
      [Year = "27-07-2024"], 
      [Year = "28-07-2024"], 
      [Year = "29-07-2024"], 
      [Year = "30-07-2024"], 
      [Year = "31-07-2024"], 
      [Year = "01-08-2024"], 
      [Year = "02-08-2024"], 
      [Year = "03-08-2024"], 
      [Year = "04-08-2024"], 
      [Year = "05-08-2024"], 
      [Year = "06-08-2024"]
    }
  ), 
  #"Changed Type" = Table.TransformColumnTypes(Source, {{"Year", type date}}), 
  Return = Table.AddColumn(#"Changed Type", "Date Record", each Date.ToRecord([Year]))
in
    Return 

The output of the above code is shown in the following image:

Date.ToRecord function in Power Query

Select the expand icon at the top, and then select the columns, and then click on Ok.

Date.ToRecord function in Power Query

After expanding, we can see the resultant columns in the image below:

Date.ToRecord function in Power Query