After I have seen a lot of questions here using the DATE_SUB()
or DATE_ADD()
functions instead of the arithmetic operators +
or -
, I was wondering if there was any difference:
Quote from the MySQL-manual:
Date arithmetic also can be performed using INTERVAL together with the + or - operator:
date + INTERVAL expr unit date - INTERVAL expr unit
So basically, these two statements return the same result:
SELECT DATE_ADD(NOW(), INTERVAL 7 DAY);
and
SELECT NOW() + INTERVAL 7 DAY;
Now my question:
Is there any difference between DATE_SUB()
and using the -
operator in MySQL? (besides readability?)