Returns the year as a short integer value in the range of 0-9999.

Syntax

YEAR ( date_expression )

Notes

  • The argument to the function must be of type DATE.
  • If date_expression is supplied as a date literal, it can be any of the valid date_literal formats where the day specification (DD) precedes the month specification (MM).
  • The result is of type SHORT.
  • If the argument expression evaluates to NULL, the result is NULL.

Example

The query returns all columns in rows in the orders table where the year in the order_date column is equal to ‘2003'. This example illustrates the YEAR function:

SELECT *
    FROM orders
    WHERE YEAR (order_date) = 2003;

Compatibility

ODBC compatible