DAX Date & Time - YEAR function

Description

Returns the year of a date as a four-digit integer in the range 1900-9999.

Syntax

YEAR (<date>) 

参数

Sr.No. 参数与说明
1

date

A date in datetime or text format, containing the year you want to find.

Return Value

An integer in the range 1900-9999.

Remarks

DAX uses datetime data type to work with dates and times.

YEAR function takes the parameter date in one of the following ways −

  • By using the DATE function.
  • As a result of other DAX formulas or DAX functions.
  • As an accepted text representation of date.

The function uses the locale and date time settings of the client computer to understand the text value in order to perform the conversion. For example,

  • If the current date/time settings represent dates in the format of Month/Day/Year, then the string "1/8/2016" is understood as a datetime value equivalent to 8th January, 2016.

  • If the current date/time settings represent dates in the format of Day/Month/Year, the same string would be understood as a datetime value equivalent to 1st August, 2016.

If the format of the string is incompatible with the current locale settings, YEAR function might return an error. For example, if your locale defines dates to be formatted as month/day/year, and the date is provided as day/month/year, then 25/1/2009 will not be interpreted as January 25th of 2009 but as an invalid date.

示例

= YEAR (DATE (2016,9,15)) returns 2016. 
= YEAR (TODAY ()) returns 2016 if TODAY () returns 12/16/2016 12:00:00 AM. 

dax_functions_date_time.html