Declaration
EXTRACT(unit FROM date)
Description
Returns a specified part of the date value as an integer. If multiple parts are specified, all values are concatenated in order.
For more information about the unit parameter, see DATE_ADD. When unit is WEEK, Sunday is considered the first day of the week.
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