Syntax
EXTRACT(unit FROM date)
Purpose
EXTRACT() returns an integer value of the specified part of date. If multiple parts are specified, all values are spliced in order.
For more information about the unit argument, see DATE_ADD. When unit is WEEK, a week starts on Sunday.
Examples
obclient> 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()): 16
1 row in set