Name

EXTRACT( )

Synopsis

EXTRACT(type FROM date)

This function extracts date or time information from a date in the format type requested. The acceptable types are the same as for DATE_ADD( ).

SELECT EXTRACT(HOUR_MINUTE FROM NOW( ))
          AS 'Time Now';
+----------+
| Time Now |
+----------+
|     1121 |
+----------+

When this SQL statement was run, it was 11:21 a.m.

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.