Scripting > UNICOM Intelligence Function Library > Date and time functions > DateAdd
 
DateAdd
Returns a date to which a specified time interval (year, quarter, month, day, week, hour, minute, or second) has been added.
Syntax
DateAdd(Val, Interval, Count)
Parameter
Val
Type: Date
The date and/or time to which you want to add the intervals.
Interval
Type: Text
The type of interval to be added, as shown below.
Count
Type: Long
Specifies the number of intervals to add. Can be negative to give an earlier date.
(return)
Type: Date
Val + (Count * Interval)
Values for Interval
Value of Interval
Description
"yyyy"
Year
"q"
Quarter
"m"
Month
"d"
Day of month
"y"
Day of year
"w"
Day of week
"ww"
Week
"h"
Hour
"n"
Minute
"s"
Second
If you are use the function in an SQL query, use ' ' (single quotation marks) instead of " " (double quotation marks) when specifying the Interval parameter.
When you add or subtract intervals of years, quarters, or months, when necessary the day is adjusted to fit the expected month. For example, when you add one month to 29 January 2003, the result is 28 February 2003.
Example
This example uses the DateAdd function to return the date and time three months from the date recorded in the DataCollection.FinishTime system variable. For example, if the date and time in the variable is 20 May 2002 2:15:43 P.M., this example would return 20 August 2002 2:15:43 P.M.
DateAdd(DataCollection.FinishTime, "m", 3)
See also
DateDiff
Date and time functions