Built-in Functions → year

year() is a scalar date function that returns the year component from a date or timestamp value. If the argument is a string, the format should be "yyyy-MM-dd HH:mm:ss".

Syntax

year(date exp)

The following table illustrates the year() parameter:

ParameterDescription
date expan expression evaluating to timestamp

Returns

int

Example

year(timestamp("2001-12-24 23:55:12.000"))

The result is 2001