Why MySQL uses the interval like 7 day and 2 hour instead of 7 days and 2 hours?


The reason behind this concept is that MySQL requires the unit keywords to be singular, regardless of the English grammar rules. If we will try to supply intervals like 7 days, 2 hours etc then MySQL will produce syntax error as follows −

mysql> Select '2017-02-25 05:04:30' + INTERVAL 2 days;
ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near 'days' at line 1

Updated on: 29-Jan-2020

69 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements