DATE

Updated on

DATE is a DAX function that returns the specified date in datetime format.

Syntax

DATE(
   Year,
   Month,
   Day
)
Argument Properties Description
Year A four digit number representing the year.
Month A number from 1 to 12 representing the month of the year.
Day A number from 1 to 31 representing the day of the month.

Return Values

Returns the specified date (datetime).

Remarks

  • The DATE function takes the integers that are input as arguments, and generates the corresponding date. The DATE function is most useful in situations where the year, month, and day are supplied by formulas. For example, the underlying data might contain dates in a format that is not recognized as a date, such as YYYYMMDD. You can use the DATE function in conjunction with other functions to convert the dates to a number that can be recognized as a date.

  • In contrast to Microsoft Excel, which stores dates as a serial number, DAX date functions always return a datetime data type. However, you can use formatting to display dates as serial numbers if you want.

  • Date and datetime can also be specified as a literal in the format dt"YYYY-MM-DD", dt"YYYY-MM-DDThh:mm:ss", or dt"YYYY-MM-DD hh:mm:ss". When specified as a literal, using the DATE function in the expression is not necessary. To learn more, see DAX Syntax | Date and time.

  • This function is not supported for use in DirectQuery mode when used in calculated columns or row-level security (RLS) rules.

Examples

Simple Date

The following formula returns the date July 8, 2009:

= DATE(2009,7,8)

Years before 1899

If the value that you enter for the year argument is between 0 (zero) and 1899 (inclusive), that value is added to 1900 to calculate the year. The following formula returns January 2, 1908: (1900+08).

= DATE(08,1,2)

Years after 1899

If year is between 1900 and 9999 (inclusive), that value is used as the year. The following formula returns January 2, 2008:

= DATE(2008,1,2)

Months

If month is greater than 12, month adds that number of months to the first month in the year specified. The following formula returns the date February 2, 2009:

= DATE(2008,14,2)

Days

If day is greater than the number of days in the month specified, day adds that number of days to the first day in the month. The following formula returns the date February 4, 2008:

= DATE(2008,1,35)

Other functions related to DATE are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/dax/date-function-dax

2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy