Returns a date to which a specified time interval has been added.
See also DateConvert, DatePart, and CreateTimeSpan.
DateAdd(datepart, number, date)
One of the following strings:
yyyy
-- Yearq
-- Quarterm
-- Monthy
-- Day of yeard
-- Dayw
-- Weekdayww
-- Weekh
-- Hourn
-- Minutes
-- SecondNumber of units of datepart to add to date (positive to get dates in the future or negative to get dates in the past).
Date/time object in the period from 100 AD to 9999 AD.
The datepart specifiers "y," "d," and "w" perform the same function -- add a certain number of days to a given date.
When passing a date/time value as a string, make sure it is enclosed in quotes. Otherwise, it is interpreted as a number representation of a date/time object, returning undesired results.
<!--- This example shows the use of DateAdd ---> ... <CFQUERY name="GetStartDate" DATASOURCE="HRApp"> SELECT StartDate, LastName, FirstName FROM Employees </CFQUERY> <P>This example uses DateAdd to determine the due date of the first review for each employee in the database. </P> <TABLE> <TR> <TD>Name</TD> <TD>Start Date</TD> <TD>Years</TD> </TR> <CFOUTPUT query="GetStartDate"> <TR> <TD>#FirstName# #LastName#</TD> <TD>#DateFormat(StartDate)#</TD> <CFSET ReviewDate = DateAdd("m", 6, StartDate)> <TD>#DateFormat(ReviewDate)#</TD> </TR> </CFOUTPUT> </TABLE> </BODY> </HTML>