YEAR()

Overview

Returns the year for the given date.

USAGE

YEAR(date)

Argument Name

Description

date

The date to evaluate

DETAILS

YEAR() is a date-time function that returns a year number for the given date.

Keep in mind that a string with a 2-digit year will be interpreted as implying a 4-digit year, so prefix shorter years with leading zeros for proper interpretation.

A 0 is returned if the date argument is 0000-00-00.

A NULL is returned if the argument is NULL.

SYNONYMS

SCHEMA

PARAMETERS

SKYSQL

PRIVILEGES

EXAMPLES

SELECT YEAR('2020-04-01'),
       YEAR('20-01-01'),
       YEAR('0020-12-01');
+--------------------+------------------+--------------------+
| YEAR('2020-04-01') | YEAR('20-01-01') | YEAR('0020-12-01') |
+--------------------+------------------+--------------------+
|               2020 |             2020 |                 20 |
+--------------------+------------------+--------------------+
SELECT YEAR('99-04-01 12:34:56');
+---------------------------+
| YEAR('99-04-01 12:34:56') |
+---------------------------+
|                      1999 |
+---------------------------+

ERROR HANDLING

FEATURE INTERACTION

RESPONSES

DIAGNOSIS

ISO 9075:2016

CHANGE HISTORY

Release Series

History

23.09

  • Present starting in MariaDB Xpand 23.09.1.

6.1

  • Present starting in MariaDB Xpand 6.1.0.

6.0

  • Present starting in MariaDB Xpand 6.0.3.

5.3

  • Present starting in MariaDB Xpand 5.3.13.

Release Series

History

6.0

  • Present starting in MariaDB Xpand 6.0.3.

5.3

  • Present starting in MariaDB Xpand 5.3.13.

Release Series

History

6.1

  • Present starting in MariaDB Xpand 6.1.0.

EXTERNAL REFERENCES