YEAR

Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API

Returns the year field from a timestamp or interval. This function is equivalent to EXTRACT(YEAR FROM ...).

Syntax 

1year(<timestamp>)
1year(<interval>)

Arguments 

Required 

  • <timestamp>: The timestamp to extract the year from.
  • <interval>: The interval to extract the number of years from.

Returns 

Returns the year as an integer.

Examples 

Extract the Year from a Timestamp 

Get the year from a timestamp.

1SELECT year(timestamp '2001-02-16 20:38:40') AS result;

Returns 2001.

Extract the Year from an Interval 

Get the number of years from an interval.

1SELECT year(interval '8 years') AS result;

Returns 8.

Related Documentation 

DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!