Watch the 7.3 Webinar On-Demand
This new release brings updates to Universal Storage, query
optimization, and usability that you won’t want to miss.
Extracts specified components from a given datetime.
EXTRACT (unit FROM dateobj)
Unit specifies the components to be extracted. See DATE_ADD for a description of valid units.
Integer
select EXTRACT(YEAR_MONTH from "2010-04-02 01:23:54");
+------------------------------------------------+
| EXTRACT(YEAR_MONTH from "2010-04-02 01:23:54") |
+------------------------------------------------+
| 201004 |
+------------------------------------------------+
select EXTRACT(MICROSECOND from "2010-04-02 01:23:54.567");
+-----------------------------------------------------+
| EXTRACT(MICROSECOND from "2010-04-02 01:23:54.567") |
+-----------------------------------------------------+
| 567000 |
+-----------------------------------------------------+