MySQL – Add Time Value (Intervals) To Date

MySQL DATE_ADD() function allow you to add a time value (Intervals) to the selected date.

MySQL ADDDATE() function is the synonym of DATE_ADD() function.

The following examples will return a date after adding 31 days with the specified date 2014-01-02.

Syntax – DATE_ADD() Function

Example:

Output:

Syntax – ADDDATE() Function

Example-1:

Output:

Example-2:

Output:

Arguments

Name Description
date Date or datetime value
INTERVAL Keyword
expr An expression specifying the interval value
unit Keyword indicating the units

The following table shows the expected form of the expr argument for each unit value.

unit Value Expected expr Format
MICROSECOND MICROSECONDS
SECOND SECONDS
MINUTE MINUTES
HOUR HOURS
DAY DAYS
WEEK WEEKS
MONTH MONTHS
QUARTER QUARTERS
YEAR YEARS
SECOND_MICROSECOND 'SECONDS.MICROSECONDS'
MINUTE_MICROSECOND 'MINUTES:SECONDS.MICROSECONDS'
MINUTE_SECOND 'MINUTES:SECONDS'
HOUR_MICROSECOND 'HOURS:MINUTES:SECONDS.MICROSECONDS'
HOUR_SECOND 'HOURS:MINUTES:SECONDS'
HOUR_MINUTE 'HOURS:MINUTES'
DAY_MICROSECOND 'DAYS HOURS:MINUTES:SECONDS.MICROSECONDS'
DAY_SECOND 'DAYS HOURS:MINUTES:SECONDS'
DAY_MINUTE 'DAYS HOURS:MINUTES'
DAY_HOUR 'DAYS HOURS'
YEAR_MONTH 'YEARS-MONTHS'

6 Responses to MySQL – Add Time Value (Intervals) To Date

  1. Tony says:

    .

    thanks for information!!

  2. Roland says:

    .

    thanks for information!

Leave a Reply

Your email address will not be published. Required fields are marked *