year(X)

Returns the year portion of a date-related value.

Syntax

year(X)

Input

Argument Type Description
X integer or decimal A scalar value or the name of a column containing date-related values
Valid values can be of the form:
  • date
  • month
  • quarter
  • date+time

For more information, see Dates and time.

Return Value

Returns the integer value (YYYY) corresponding to the year portion of the date-related value given as input.

If the input values are not in one of the supported formats listed above, the function returns an erroneous or illogical output.

Example

In the Monthly Statewide Seasonally Adjusted Unemployment Statistics table (pub.fin.fred2.bls.smsa), you can create a computed column that displays an integer value corresponding to the year portion of the month value in the column named month:

<base table="pub.fin.fred2.bls.smsa" label="Example: year(X)"/>
<willbe name="example" value="year(month)" label="Year" format="type:nocommas"/>
<colord cols="month,example"/>
Note: The computed column is formatted using the nocommas display format so that the year will appear without commas (i.e., 1976 as opposed to 1,976).

For a month value of 09/76 (X=197609), the result would be 1976.