Get the hour, minute and second time components : SECOND « Date Time « SQL / MySQL






Get the hour, minute and second time components

     
mysql>
mysql> CREATE TABLE IF NOT EXISTS labor_day
    -> (
    ->   id     INT     AUTO_INCREMENT PRIMARY KEY,
    ->   date   DATETIME NOT NULL
    -> );
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> INSERT INTO labor_day (date) VALUES ("2005-09-05 12:45:30");
Query OK, 1 row affected (0.00 sec)

mysql>
mysql> # get the hour, minute and second time components
mysql> SELECT HOUR(date), MINUTE(date), SECOND(date)
    -> FROM labor_day;
+------------+--------------+--------------+
| HOUR(date) | MINUTE(date) | SECOND(date) |
+------------+--------------+--------------+
|         12 |           45 |           30 |
+------------+--------------+--------------+
1 row in set (0.00 sec)

mysql>
mysql>
mysql> # delete this sample table
mysql> DROP TABLE IF EXISTS labor_day;
Query OK, 0 rows affected (0.00 sec)

   
    
    
    
    
  








Related examples in the same category

1.Extracts the seconds from a time value: SECOND(