Compare time value : Time « Date Time « SQL / MySQL






Compare time value

     
mysql>
mysql> CREATE   TABLE MATCHES_SPECIAL
    ->         (MATCHNO         INTEGER NOT NULL,
    ->          TEAMNO          INTEGER NOT NULL,
    ->          EmployeeNO        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> 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, END_TIME
    -> FROM     MATCHES_SPECIAL
    -> WHERE    ADDTIME(END_TIME, '06:30:00') <= '24:00:00';
+---------+----------+
| MATCHNO | END_TIME |
+---------+----------+
|       1 | 16:50:09 |
+---------+----------+
1 row in set (0.00 sec)

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

   
    
    
    
    
  








Related examples in the same category

1.Get Current time
2.Extract the entire time value by using the TIME() function: TIME(
3.Comparing Times to One Another
4.TIME type column
5.Alias column for constant time value
6.Calculates the sum of the two TIME values
7.Return the total working time, using SUM.