Bug #69109 MySQL 5.0.77 timediff bug

Submitted: 30 Apr 2013 20:05 Modified: 6 May 2013 14:19
Reporter: Doug Ehlenberger Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: General Severity:S2 (Serious)
Version:5.0.77 OS:Linux
Assigned to: CPU Architecture:Any
Tags: timediff

[30 Apr 2013 20:05] Doug Ehlenberger
Description:
I noticed a possible bug with the timediff function in version 5.0.77. The details of this are presented in the How to repeat section. A series of queries and the output produced by them are shown. Is timediff() actually returning a time value? It seems I have to explicitly cast it to a time value to make the comparison work? See below.

How to repeat:
select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ), time( 25000 );
output: 06:00:00, 02:50:00 (correct 6 hours and 2 hours 50 minutes) 

select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= time( 25000 );
output: 1 (incorrect 6 hours is not less than 2 hours 50 minutes?)

select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= time( '02:50:00' );
output: 1 (incorrect 6 hours is not less than 2 hours 50 minutes?)

select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= cast( '02:50:00' as time );
output: 1 (incorrect 6 hours is not less than 2 hours 50 minutes?)

select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= '02:50:00';
output: 0 (correct)

select cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= time( 25000 );
output: 0 (correct)

select cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= time( '02:50:00' );
output: 0 (correct)

select cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= cast( '02:50:00' as time );
output: 0 (correct)

select cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= '02:50:00';
output: 0 (correct)

Suggested fix:
Make sure timediff() is actually returning a time value as indicated in the documentation.
[6 May 2013 14:19] MySQL Verification Team
Thanks for your report, I can't reproduce your problem with the latest GA versions( 5.5.x, 5.6.x, 5.1.x and 5.0.x)

We do not fix bugs that are not repeatable with current versions.
[6 May 2013 14:22] MySQL Verification Team
### 5.6.11  - works as expected

[root@ushastry mysql-5.6.11-release]# bin/mysql -u root -p --port=3306 --protocol=TCP test
Enter password: 
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.11-debug-log Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 
mysql> select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ), time( 25000 );
+----------------------------------------------------------+---------------+
| timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) | time( 25000 ) |
+----------------------------------------------------------+---------------+
| 06:00:00                                                 | 02:50:00      |
+----------------------------------------------------------+---------------+
1 row in set (0.01 sec)

mysql> select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= time( 25000 );
+---------------------------------------------------------------------------+
| timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= time( 25000 ) |
+---------------------------------------------------------------------------+
|                                                                         0 |
+---------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= time( '02:50:00' );
+--------------------------------------------------------------------------------+
| timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= time( '02:50:00' ) |
+--------------------------------------------------------------------------------+
|                                                                              0 |
+--------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= cast( '02:50:00' as time );
+----------------------------------------------------------------------------------------+
| timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= cast( '02:50:00' as time ) |
+----------------------------------------------------------------------------------------+
|                                                                                      0 |
+----------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= '02:50:00';
+------------------------------------------------------------------------+
| timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= '02:50:00' |
+------------------------------------------------------------------------+
|                                                                      0 |
+------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= time( 25000 );
+-------------------------------------------------------------------------------------------+
| cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= time( 25000 ) |
+-------------------------------------------------------------------------------------------+
|                                                                                         0 |
+-------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= time( '02:50:00' );
+------------------------------------------------------------------------------------------------+
| cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= time( '02:50:00' ) |
+------------------------------------------------------------------------------------------------+
|                                                                                              0 |
+------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= cast( '02:50:00' as time );
+--------------------------------------------------------------------------------------------------------+
| cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= cast( '02:50:00' as time ) |
+--------------------------------------------------------------------------------------------------------+
|                                                                                                      0 |
+--------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= '02:50:00';
+----------------------------------------------------------------------------------------+
| cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= '02:50:00' |
+----------------------------------------------------------------------------------------+
|                                                                                      0 |
+----------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
[6 May 2013 14:22] MySQL Verification Team
### 5.5.31  - works as expected

root@ushastry mysql-5.5.31]# 130501 10:58:38 mysqld_safe Logging to '/tmp/5531_/ushastry.err'.
130501 10:58:39 mysqld_safe Starting mysqld daemon with databases from /tmp/5531_

[root@ushastry mysql-5.5.31]# bin/mysql -u root -p --port=3306 --protocol=TCP test
Enter password: 
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.31-debug-log Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ), time( 25000 );
+----------------------------------------------------------+---------------+
| timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) | time( 25000 ) |
+----------------------------------------------------------+---------------+
| 06:00:00                                                 | 02:50:00      |
+----------------------------------------------------------+---------------+
1 row in set (0.03 sec)

mysql> select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= time( 25000 );
+---------------------------------------------------------------------------+
| timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= time( 25000 ) |
+---------------------------------------------------------------------------+
|                                                                         0 |
+---------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= time( '02:50:00' );
+--------------------------------------------------------------------------------+
| timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= time( '02:50:00' ) |
+--------------------------------------------------------------------------------+
|                                                                              0 |
+--------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= cast( '02:50:00' as time );
+----------------------------------------------------------------------------------------+
| timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= cast( '02:50:00' as time ) |
+----------------------------------------------------------------------------------------+
|                                                                                      0 |
+----------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= '02:50:00';
+------------------------------------------------------------------------+
| timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= '02:50:00' |
+------------------------------------------------------------------------+
|                                                                      0 |
+------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= time( 25000 );
+-------------------------------------------------------------------------------------------+
| cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= time( 25000 ) |
+-------------------------------------------------------------------------------------------+
|                                                                                         0 |
+-------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= time( '02:50:00' );
+------------------------------------------------------------------------------------------------+
| cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= time( '02:50:00' ) |
+------------------------------------------------------------------------------------------------+
|                                                                                              0 |
+------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= cast( '02:50:00' as time );
+--------------------------------------------------------------------------------------------------------+
| cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= cast( '02:50:00' as time ) |
+--------------------------------------------------------------------------------------------------------+
|                                                                                                      0 |
+--------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= '02:50:00';
+----------------------------------------------------------------------------------------+
| cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= '02:50:00' |
+----------------------------------------------------------------------------------------+
|                                                                                      0 |
+----------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql>
[6 May 2013 14:23] MySQL Verification Team
### 5.1.68 - works as expected

[root@cluster-repo mysql-5.1.68]# bin/mysql -u root -p --port=5168 --protocol=TCP
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.68 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
mysql> select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ), time( 25000 );
+----------------------------------------------------------+---------------+
| timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) | time( 25000 ) |
+----------------------------------------------------------+---------------+
| 06:00:00                                                 | 02:50:00      |
+----------------------------------------------------------+---------------+
1 row in set (0.00 sec)

mysql> select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= time( 25000 );
+---------------------------------------------------------------------------+
| timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= time( 25000 ) |
+---------------------------------------------------------------------------+
|                                                                         0 |
+---------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= time( '02:50:00' );
+--------------------------------------------------------------------------------+
| timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= time( '02:50:00' ) |
+--------------------------------------------------------------------------------+
|                                                                              0 |
+--------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= cast( '02:50:00' as time );
+----------------------------------------------------------------------------------------+
| timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= cast( '02:50:00' as time ) |
+----------------------------------------------------------------------------------------+
|                                                                                      0 |
+----------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= '02:50:00';
+------------------------------------------------------------------------+
| timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= '02:50:00' |
+------------------------------------------------------------------------+
|                                                                      0 |
+------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= time( 25000 );
+-------------------------------------------------------------------------------------------+
| cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= time( 25000 ) |
+-------------------------------------------------------------------------------------------+
|                                                                                         0 |
+-------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= time( '02:50:00' );
+------------------------------------------------------------------------------------------------+
| cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= time( '02:50:00' ) |
+------------------------------------------------------------------------------------------------+
|                                                                                              0 |
+------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= cast( '02:50:00' as time );
+--------------------------------------------------------------------------------------------------------+
| cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= cast( '02:50:00' as time ) |
+--------------------------------------------------------------------------------------------------------+
|                                                                                                      0 |
+--------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= '02:50:00';
+----------------------------------------------------------------------------------------+
| cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= '02:50:00' |
+----------------------------------------------------------------------------------------+
|                                                                                      0 |
+----------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql>
[6 May 2013 14:23] MySQL Verification Team
### 5.0.96  - works as expected

[root@cluster-repo mysql-5.0.96]# bin/mysql -u root -p --port=5096 --protocol=TCP
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.96 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
mysql> select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ), time( 25000 );
+----------------------------------------------------------+---------------+
| timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) | time( 25000 ) |
+----------------------------------------------------------+---------------+
| 06:00:00                                                 | 02:50:00      |
+----------------------------------------------------------+---------------+
1 row in set (0.00 sec)

mysql> select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= time( 25000 );
+---------------------------------------------------------------------------+
| timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= time( 25000 ) |
+---------------------------------------------------------------------------+
|                                                                         0 |
+---------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= time( '02:50:00' );
+--------------------------------------------------------------------------------+
| timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= time( '02:50:00' ) |
+--------------------------------------------------------------------------------+
|                                                                              0 |
+--------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= cast( '02:50:00' as time );
+----------------------------------------------------------------------------------------+
| timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= cast( '02:50:00' as time ) |
+----------------------------------------------------------------------------------------+
|                                                                                      0 |
+----------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= '02:50:00';
+------------------------------------------------------------------------+
| timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= '02:50:00' |
+------------------------------------------------------------------------+
|                                                                      0 |
+------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= time( 25000 );
+-------------------------------------------------------------------------------------------+
| cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= time( 25000 ) |
+-------------------------------------------------------------------------------------------+
|                                                                                         0 |
+-------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= time( '02:50:00' );
+------------------------------------------------------------------------------------------------+
| cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= time( '02:50:00' ) |
+------------------------------------------------------------------------------------------------+
|                                                                                              0 |
+------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= cast( '02:50:00' as time );
+--------------------------------------------------------------------------------------------------------+
| cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= cast( '02:50:00' as time ) |
+--------------------------------------------------------------------------------------------------------+
|                                                                                                      0 |
+--------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= '02:50:00';
+----------------------------------------------------------------------------------------+
| cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= '02:50:00' |
+----------------------------------------------------------------------------------------+
|                                                                                      0 |
+----------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
[6 May 2013 14:24] MySQL Verification Team
#### 5.0.77  - affected

[root@cluster-repo mysql-5.0.77]# bin/mysql -u root -p --port=5077 --protocol=TCP
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.77 MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>
mysql> select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ), time( 25000 );
+----------------------------------------------------------+---------------+
| timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) | time( 25000 ) |
+----------------------------------------------------------+---------------+
| 06:00:00                                                 | 02:50:00      |
+----------------------------------------------------------+---------------+
1 row in set (0.00 sec)

mysql> select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= time( 25000 );
+---------------------------------------------------------------------------+
| timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= time( 25000 ) |
+---------------------------------------------------------------------------+
|                                                                         1 |
+---------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= time( '02:50:00' );
+--------------------------------------------------------------------------------+
| timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= time( '02:50:00' ) |
+--------------------------------------------------------------------------------+
|                                                                              1 |
+--------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= cast( '02:50:00' as time );
+----------------------------------------------------------------------------------------+
| timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= cast( '02:50:00' as time ) |
+----------------------------------------------------------------------------------------+
|                                                                                      1 |
+----------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= '02:50:00';
+------------------------------------------------------------------------+
| timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) <= '02:50:00' |
+------------------------------------------------------------------------+
|                                                                      0 |
+------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= time( 25000 );
+-------------------------------------------------------------------------------------------+
| cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= time( 25000 ) |
+-------------------------------------------------------------------------------------------+
|                                                                                         0 |
+-------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= time( '02:50:00' );
+------------------------------------------------------------------------------------------------+
| cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= time( '02:50:00' ) |
+------------------------------------------------------------------------------------------------+
|                                                                                              0 |
+------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= cast( '02:50:00' as time );
+--------------------------------------------------------------------------------------------------------+
| cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= cast( '02:50:00' as time ) |
+--------------------------------------------------------------------------------------------------------+
|                                                                                                      0 |
+--------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= '02:50:00';
+----------------------------------------------------------------------------------------+
| cast( timediff( '2013-04-28 20:10:00', '2013-04-28 14:10:00' ) as time ) <= '02:50:00' |
+----------------------------------------------------------------------------------------+
|                                                                                      0 |
+----------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.062 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.