EXTRACT
Syntax
EXTRACT(unit FROM date)
Description
Returns the specified part of the date value as an integer. If multiple parts are specified, all values are concatenated in sequence.
For more information about the unit parameter, see DATE_ADD. When unit is WEEK, the first day of the week is Sunday.
Examples
SELECT EXTRACT(WEEK FROM '2013-01-01'),
EXTRACT(WEEK FROM '2013-01-06'),
EXTRACT(YEAR_MONTH FROM '2012-03-09'),
EXTRACT(DAY FROM NOW())\G;
*************************** 1. row ***************************
EXTRACT(WEEK FROM '2013-01-01'): 0
EXTRACT(WEEK FROM '2013-01-06'): 1
EXTRACT(YEAR_MONTH FROM '2012-03-09'): 201203
EXTRACT(DAY FROM NOW()): 17
1 row in set (0.000 sec)