top of page
![](https://static.wixstatic.com/media/11062b_fac51a38acf24ea2aa030216e01a0ea3f000.jpg/v1/fill/w_288,h_162,al_c,q_80,usm_0.66_1.00_0.01,blur_2,enc_auto/11062b_fac51a38acf24ea2aa030216e01a0ea3f000.jpg)
Syntax:
EXTRACT(unit FROM date)
The EXTRACT() function uses the same kinds of unit specifiers as
DATE_ADD() or DATE_SUB(), but extracts parts from the date rather than
performing date arithmetic. For information on the unit argument.
Example
mysql> SELECT EXTRACT(YEAR FROM '2019-07-02');
-> 2019
mysql> SELECT EXTRACT(YEAR_MONTH FROM '2019-07-02 01:02:03');
-> 201907
mysql> SELECT EXTRACT(DAY_MINUTE FROM '2019-07-02 01:02:03');
-> 20102
mysql> SELECT EXTRACT(MICROSECOND
-> FROM '2003-01-02 10:30:00.000123');
-> 123
bottom of page