YEAR()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Returns the year for the given date.
USAGE
YEAR(date)
Argument Name | Description |
---|---|
| 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
.
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 |
+---------------------------+