Command Reference : String and Date Function Reference
  
 
@dateadd
Syntax: @dateadd(d, offset, u[, f])
Argument 1: date number, d
Argument 2: number of time units, offset
Argument 3: time unit, u
Argument 4: double, control flag, f
Return: date number
Returns the date number given by d offset by offset time units as specified by the time unit string u.
The valid time unit string values are: “A” or “Y” (annual), “S” (semi-annual), “Q” (quarters), “MM” (months), “WW” (weeks), “DD” (days), “B” (business days), “HH” (hours), “MI” (minutes), “SS” (seconds).
When the time unit u is business days, the optional parameter f controls how a non-business day date number d is handled. When f is absent or equal to zero, the date number d is automatically advanced to the next business day before offset is applied. Otherwise, when f is non-zero automatic advancement is suppressed. Consequently, when f is non-zero and offset is 0 the function returns the original date number d (a non-business day).
Example:
Suppose that the value of d is 730088.0 (midnight, December 1, 1999). Then we can add and subtract 10 days from the date by using the functions
@dateadd(730088.0, 10, "dd")
@dateadd(730088.0, -10, "dd")
which return 730098.0 (December 11, 1999) and (730078.0) (November 21, 1999). Note that these results could have been obtained by taking the original numeric value plus or minus 10.
To add 5 weeks to the existing date, simply specify “W” or “WW” as the time unit string:
@dateadd(730088.0, 5, "ww")
returns 730123.0 (January 5, 2000).
Suppose that the value of d is 730091.0 (midnight, December 4, 1999), which is a Saturday:
@dateadd(730091.0, -1, "b")
and
@dateadd(730091.0, -1, "b", 1)
both return 730090.0 (December 3, 1999), the preceding Friday.
@dateadd(730091.0, 0, "b")
returns 730093.0 (December 6, 1999), the following Monday, while
@dateadd(730091.0, 0, "b", 1)
returns 730091.0 (December 4, 1999), the original Saturday.
@dateadd(730091.0, 1, "b")
returns 730094.0 (December 7, 1999), the following Tuesday, while
@dateadd(730091.0, 1, "b", 1)
returns 730093.0 (December 6, 1999), the following Monday.
The valid time unit string values are: “A” or “Y” (annual), “S” (semi-annual), “Q” (quarters), “MM” (months), “WW” (weeks), “DD” (days), “B” (business days), “HH” (hours), “MI” (minutes), “SS” (seconds).