Name
DATE_ADD()
Synopsis
DATE_ADD(date
, INTERVALexpr
unit
)
Returns the result of adding the expression
expr
using the units
unit
to the
date
. The date
argument is the starting date or DATETIME
value, and
expr
may start with a -
symbol for negative intervals. Table D-1 shows the interval types supported
and the expected expr
values. Note the
examples in this table that show where it is necessary to surround the
expr
value with quotes for MySQL to
interpret them correctly (although, if you are ever in doubt, adding
the quotes will always work).
Type | Expected expr value | Example |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
You can also use the DATE_SUB
function to subtract date intervals. However, itâs not actually
necessary for you to use the DATE_ADD
or DATE_SUB
functions, as you can use date arithmetic directly in MySQL. This ...
Get Learning PHP, MySQL, JavaScript, and CSS, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.