year() function

Extract the year part from a date, or the number of years from a Interval

Syntax

year(date)
year(Interval)

Arguments

date - is date or datetime. The date to extract the year from.
Interval - is Interval. The Interval to return the number of years from.

Example

year('2012-05-12') -> 2012
year(tointerval('3 Years')) -> 3
year(age('2012-01-01','2010-01-01')) -> 1.9986..