MySQL Tutorial/Date Time Functions/YEAR
Версия от 13:44, 26 мая 2010; (обсуждение)
select YEAR("1973-07-20");
mysql>
mysql>
mysql> select YEAR("1989-07-20");
+--------------------+
| YEAR("1989-07-20") |
+--------------------+
| 1989 |
+--------------------+
1 row in set (0.00 sec)
mysql>
YEAR(date) returns the 4-digit numeric year of a given date:
mysql>
mysql> SELECT YEAR("01/12/25 11:00:00");
+---------------------------+
| YEAR("01/12/25 11:00:00") |
+---------------------------+
| 2001 |
+---------------------------+
1 row in set (0.00 sec)
mysql>
YEAR(date) returns the year for date, in the range 1000 to 9999, or 0 for the "zero" date.
mysql>
mysql> SELECT YEAR("98-02-03");
+------------------+
| YEAR("98-02-03") |
+------------------+
| 1998 |
+------------------+
1 row in set (0.00 sec)
mysql>