DATEADD Function



Function Type

Predefined function

Syntax

DATEADD( <interval>, <increment>, <dateValue> )

Description

Add or subtract a time interval to or from a date value.

Argument

Description

<interval>

String describing "part" of the time interval to be added to the <dateValue>. Shown below is a list of valid time interval parts:

Time Parts

Interval Value

Year

y

Quarter

q

Month

M

Day of Year

D

Day of Month

d

Weekday

E

Week

w

Hour in am/pm (1-12)

h

Hour in day (0-23)

H

Minute

m

Second

s

The intervals for Day of Year ("D"), Day of Month ("d"), and Weekday ("E") can be used interchangeably to add days to a date.

Each part of the date is adjusted according to the rules of the Gregorian calendar. This includes adjustments made for leap years and the different number of days in each month.

<increment>

Integer specifying the number to increment the <interval> or time intervals to be added to <dateValue>. Positive values add time to the date. Negative values subtract time from the date.

The <increment> argument is treated as a whole number. Fractional parts of the value are ignored.

<dateValue>

Date value to which a specified number of time intervals will be added.

Returns

Date

Example

This example returns a result of 28-Feb-95. The year 1995 is not a leap year, so the last day of February is the 28th. After the months are added to the original date, the day value is adjusted backward to ensure that the resultant date is valid.

DATEADD("M", 7, STR2DATE("31-Jul-94", "dd-MMM-yyyy"))


 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*