Mega Code Archive

 
Categories / MySQL / Date Time
 

Extract the year from a date value by using the YEAR() function

mysql> mysql> mysql> mysql> SELECT YEAR('2004-12-31 23:59:59'); +-----------------------------+ | YEAR('2004-12-31 23:59:59') | +-----------------------------+ |                        2004 | +-----------------------------+ 1 row in set (0.00 sec) mysql>