#### DateAdd

##### DateAdd(intervalType, nIntervals, startDateTime)

Returns a DateTime value to which a specified number of time intervals have been added.

This function is used to add interval of time to a DateTime. Its main feature is that the DateTime returned will always be valid. For example, the function takes into account such factors as the number of days in a month and leap years. If you want to add or subtract days to a DateTime, you could use the addition and subtraction operators instead of the function with the "d" parameter. However, this function also handles other types of intervals such as adding months or hours to a DateTime.

Parameters

- intervalType - A String expression specifying the interval of time to be added.

  IntervalType value | Description
  --- | ---
  yyyy | Year
  q | Quarter (3-month period)
  m | Month
  y | Day of year
  d | Day
  w | Weekday
  ww | Week (7-day period)
  h | Hour
  n | Minute
  s | Second

- nIntervals - A Number or numeric expression specifying the number of intervals to be added. It can be positive (to get DateTimes from the future), or negative (to get DateTimes from the past).
- startDateTime - The DateTime value to which the intervals are to be added.

Return value

A DateTime value.

Examples

- `DateAdd("d",-32,ToDateTime(1999,9,28))` - Returns the DateTime value for 1999-8-27 00:00:00.
- `DateAdd("m",1,ToDateTime(1996,1,31))` - Returns the DateTime value for 1996-2-29 00:00:00. Notice that DateAdd will not return the invalid value 1996-2-31 00:00:00.
- `DateAdd("q",17,ToDateTime(1999,9,28))` - Returns the DateTime value for 2003-12-28 00:00:00.
- `DateAdd("h",-400,ToDateTime(1999,9,28))` - Returns the DateTime value for 1999-9-11 08:00:00. In other words, this is the result of subtracting 400 hours from 1999-9-28 00:00:00.

Notes:

- To add days to a DateTime, you can use any of the interval type parameters "y", "d" or "w". They all have the same effect for DateAdd.
- DateAdd returns a DateTime value and not a Date value. However, you may need to convert this DateTime value to a Date value in certain situations (such as if you wanted to assign the value returned by DateAdd to a Date type variable). To convert to a Date value, use DateAdd in combination with the ToDate type conversion function. For example, the following returns the Date value for October 6, 1997.

  `ToDate(DateAdd("yyyy",-2,ToDateTime(1999,10,6)))`