MySQL EXTRACT() Function
Definition and Usage
The EXTRACT() function extracts parts from a date.
Syntax
EXTRACT(unit FROM date)Parameter Values
| Parameter | Description |
|---|---|
| unit | Required. The unit type of the interval. Can be one of the following
values:
|
| date | Required. The date or datetime value from which the date part is to be extracted |
Technical Details
| Works in: | MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23 |
|---|
More Examples
Example
Extract the minute from a datetime:
SELECT EXTRACT(MINUTE FROM "2017-06-15 09:34:21");
Try it Yourself »
Example
Extract the year and month from a datetime:
SELECT EXTRACT(YEAR_MONTH FROM "2017-06-15 09:34:21");
Try it Yourself »

