Extract the month from a given date.
SELECT EXTRACT(MONTH FROM “2017-06-15”); |
The EXTRACT() function retrieves a specific part from a given date.
EXTRACT(part FROM date) |
Parameter |
Description |
Part |
Required. The part to extract, which can be one of the following:
|
date |
Required. The date from which to extract a part. |
Works in: |
From MySQL version 4.0 |
Extract the week from a given date.
SELECT EXTRACT(WEEK FROM “2017-06-15”); |
Extract the minute from a given datetime.
SELECT EXTRACT(MINUTE FROM “2017-06-15 09:34:21”); |
Extract the year and month from a given datetime.
SELECT EXTRACT(YEAR_MONTH FROM “2017-06-15 09:34:21”); |