#date

Updated on

#date is a Power Query M function that creates a date value from numbers representing the year, month, and day.

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

Syntax

#date(
   year as number,
   month as number,
   day as number,
) as date

Description

#date creates a date value using whole numbers for the year, month, and day. The following conditions should be met:

  • The year must be a whole number within the range of 1 to 9999.
  • The month must be a whole number within the range of 1 to 12.
  • The day must be a whole number within the range of 1 to 31.

If any of these conditions are not satisfied, the function raises an error. This ensures that the resulting date value is valid and corresponds to a real calendar date.

Examples

Returns the date June 10, 2023.

#date( 2023, 6, 10 )

You can easily transform a date into the day, month or year portion.

Date.Day(   #date( 2023, 6, 10 ) ) // Returns 10

Date.Month( #date( 2023, 6, 10 ) ) // Returns 6

Date.Year(  #date( 2023, 6, 10 ) ) // Returns 2023

Learn more about #date in the following articles:

Other functions related to #date are:

BI Gorilla Youtube Channel

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/sharpdate