EXTRACT()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Enterprise Server
Topics on this page:
Overview
A description for this Function has not yet been added to this Documentation.
EXAMPLES
CREATE TABLE t1 (a DATE);
INSERT INTO t1 VALUES
('0000-00-00'), ('0000-00-01'),
('0000-01-00'), ('0000-01-01'),
('0001-00-00'), ('0001-00-01'),
('0001-01-00'), ('0001-01-01');
SELECT a, EXTRACT(DAY FROM a) FROM t1;
+------------+---------------------+
| a | EXTRACT(DAY FROM a) |
+------------+---------------------+
| 0000-00-00 | 0 |
| 0000-00-01 | 1 |
| 0000-01-00 | 0 |
| 0000-01-01 | 1 |
| 0001-00-00 | 0 |
| 0001-00-01 | 1 |
| 0001-01-00 | 0 |
| 0001-01-01 | 1 |
+------------+---------------------+
SELECT EXTRACT(HOUR FROM '2019-01-31 10:01:00');
+------------------------------------------+
| EXTRACT(HOUR FROM '2019-01-31 10:01:00') |
+------------------------------------------+
| 10 |
+------------------------------------------+
SELECT EXTRACT(YEAR FROM '2019-01-31 10:01:00');
+------------------------------------------+
| EXTRACT(YEAR FROM '2019-01-31 10:01:00') |
+------------------------------------------+
| 2019 |
+------------------------------------------+
SELECT EXTRACT(DAY FROM '2019-01-31 10:01:00');
+-----------------------------------------+
| EXTRACT(DAY FROM '2019-01-31 10:01:00') |
+-----------------------------------------+
| 31 |
+-----------------------------------------+
SELECT EXTRACT(MINUTE FROM '2019-01-31 10:01:00');
+--------------------------------------------+
| EXTRACT(MINUTE FROM '2019-01-31 10:01:00') |
+--------------------------------------------+
| 1 |
+--------------------------------------------+
SELECT EXTRACT(SECOND FROM '2019-01-31 10:01:00');
+--------------------------------------------+
| EXTRACT(SECOND FROM '2019-01-31 10:01:00') |
+--------------------------------------------+
| 0 |
+--------------------------------------------+
SELECT EXTRACT(MICROSECOND FROM '2019-01-31 10:01:00.000123');
+--------------------------------------------------------+
| EXTRACT(MICROSECOND FROM '2019-01-31 10:01:00.000123') |
+--------------------------------------------------------+
| 123 |
+--------------------------------------------------------+
CHANGE HISTORY
EXTERNAL REFERENCES
Additional information on this topic may be found in the MariaDB Public Knowledge Base.