Recall that mysql has two different types depending on date and time: The suffix _SUB is designed to subtract the date minus the interval that returns the date strong>. The suffix _DIFF is designed to get the difference between two dates by returning the interval (BTW, note that only the first has the opposite analogue: _ADD )
The +/- signs must be used for the first (ADD / SUB), so MYSQL expects an interval as the second argument.
DATE = DATE_ADD(DATE,INTERVAL) Also accepts + DATE = DATE_SUB(DATE,INTERVAL) Also accepts - INTERVAL = DATE_DIFF(DATE,DATE )
See the doc here , the bit starts with:
Date arithmetic also can be performed using INTERVAL together with the + or - operator...
Therefore, it is incorrect to use the - value to accept the difference between the two dates. Now MYSQL, faced with incorrect conclusions, is trying to do everything possible (instead of throwing an error), sometimes it's good, sometimes not.
source share