For each match, get the time it starts, and get the time it starts plus eight hours. : ADDTIME « Date Time « SQL / MySQL






For each match, get the time it starts, and get the time it starts plus eight hours.

      
mysql>
mysql> CREATE TABLE MATCHES_SPECIAL(
    ->     MATCHNO INTEGER NOT NULL,
    ->     TEAMNO INTEGER NOT NULL,
    ->     PLAYERNO INTEGER NOT NULL,
    ->     WON SMALLINT NOT NULL,
    ->     LOST SMALLINT NOT NULL,
    ->     START_DATE DATE NOT NULL,
    ->     START_TIME TIME NOT NULL,
    ->     END_TIME TIME NOT NULL,
    ->     PRIMARY KEY (MATCHNO)
    -> );
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql>
mysql> INSERT INTO MATCHES_SPECIAL VALUES (1, 1, 6, 3, 1, '2004-10-25', '14:10:12', '16:50:09');
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO MATCHES_SPECIAL VALUES (2, 1, 44, 3, 2, '2004-10-25', '17:00:00', '17:55:48');
Query OK, 1 row affected (0.00 sec)

mysql>
mysql>
mysql> SELECT MATCHNO, START_TIME,
    -> ADDTIME(START_TIME, '08:00:00')
    -> FROM MATCHES_SPECIAL;
+---------+------------+---------------------------------+
| MATCHNO | START_TIME | ADDTIME(START_TIME, '08:00:00') |
+---------+------------+---------------------------------+
|       1 | 14:10:12   | 22:10:12                        |
|       2 | 17:00:00   | 25:00:00                        |
+---------+------------+---------------------------------+
2 rows in set (0.00 sec)

mysql>
mysql> drop table matches_special;
Query OK, 0 rows affected (0.00 sec)

mysql>

   
    
    
    
    
    
  








Related examples in the same category

1.Add time with ADDTIME function
2.Returns the number of workdays with ten or more hours