Database Reference
In-Depth Information
Figure 11.11
DATE_ADD() adds time periods to given dates.
Table 11.4 shows some of the period types that you can use with DATE_ADD() and other
related functions to specify your time period.
Table 11.4
Some time period types.
Type
Value format
Timeperiod example
SECOND
numeric
INTERVAL 5 SECOND
MINUTE
numeric
INTERVAL 5 MINUTE
HOUR
numeric
INTERVAL 5 HOUR
DAY
numeric
INTERVAL 5 DAY
MONTH
numeric
INTERVAL 5 MONTH
YEAR
numeric
INTERVAL 5 YEAR
HOURSECOND
“hours:minutes:seconds”
INTERVAL “05:10:00” HOURSECOND
HOURMINUTE
“hours:minutes”
INTERVAL “05:10” HOURMINUTE
DAYHOUR
“days hours”
INTERVAL “5 12” DAYHOUR
A full listing of these types is in the MySQL online documentation.
ADDDATE
The ADDDATE() function works exactly the same as the DATE_ADD() function just
described. The format is therefore:
ADDDATE( aDate, INTERVAL timeperiod )
Please refer to the DATE_ADD section above for further information.
DATE_SUB
The DATE_SUB() function works similarly to the DATE_ADD() function, but it subtracts
the time period instead. The format is:
DATE_SUB( aDate, INTERVAL timeperiod )
 
Search WWH ::




Custom Search