Топ-100
 

EXTRACT

База данных: MySQL
Текст

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, see
https://dev.mysql.com/doc/refman/8.0/en/expressions.html#temporal-inter
vals.

URL: https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html

Пример

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