Developer Documentation Library > 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(<value>, <interval>, <count>)
Parameter
<value>
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. See Value of Interval.
<count>
Type: Long
Specifies the number of intervals to add. Can be negative to give an earlier date.
(return)
Type: Date
<value> + (<count> * <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 2023, the result is 28 February 2023.
Example
This example returns the date and time three months from the date in the DataCollection.FinishTime system variable. For example, if the date is 20 January 2023 2:15:43 P.M., this example returns 20 April 2023 2:15:43 P.M.
DateAdd(DataCollection.FinishTime, "m", 3)
See also
DateDiff
Date and time functions