How does comparison operator work with date values in MySQL?



Comparison operator between dates will work in a logical way. In the following example, while comparing two dates, MySQL is simply comparing two numbers or string −

mysql> select 20171027 < 20150825;
+---------------------------+
| 20171027 < 20150825       |
+---------------------------+
|                      0    |
+---------------------------+
1 row in set (0.00 sec)

The 0 output shows that the result of the above query is FALSE.

mysql> select 20171027 > 20150825;
+--------------------------+
| 20171027 > 20150825      |
+--------------------------+
|                      1   |
+--------------------------+
1 row in set (0.00 sec)

The output ‘1’ shows that the result of the above query is TRUE.


Advertisements