#date Function in Power Query
The #date function is used to create a date value from year, month, and day.
Syntax
#date(year as number, month as number, day as number) as date
Example: Create dates in the table using the #date function.
Power Query M
let
MyTable = Table.FromRecords(
{
[CustomerID = 1, Name = "Ashish", Date = #date(2024,4,7)],
[CustomerID = 2, Name = "Katrina", Date = #date(2023,8,9)],
[CustomerID = 3, Name = "Alia", Date = #date(2024,9,17)],
[CustomerID = 4, Name = "Vicky", Date = #date(2024,2,27)],
[CustomerID = 5, Name = "Mohini", Date = #date(2024,6,16)],
[CustomerID = 6, Name = "Meenakshi", Date = #date(2024,5,19)],
[CustomerID = 7, Name = "Esha", Date = #date(2023,4,30)],
[CustomerID = 8, Name = "Anjali", Date = #date(2024,9,2)]
}
)
in
MyTable The output of the above code is shown in the following image:
