User Guide
DateAdd 439
DateAdd
Description
Adds units of time to a date.
Returns
A date/time object.
Category
Date and time functions
Function syntax
DateAdd("datepart", number, "date")
See also
DateConvert, DatePart, CreateTimeSpan
History
ColdFusion MX 6.1: Added the datepart character L or l to represent milliseconds.
Parameters
Usage
The datepart specifiers y, d, and w add a number of days to a date.
When passing a date/time object as a string, you must enclose it in quotation marks. Otherwise, it
is interpreted as a numeric representation of a date/time object.
Example
<!--- This example shows the use of DateAdd --->
<cfparam name="value" default="70">
<cfparam name="type" default="m">
<!--- if numbers passed, then use those --->
<cfif IsDefined("form.value")>
<cfset value = form.value>
</cfif>
Parameter Description
datepart String:
• yyyy: Year
• q: Quarter
• m: Month
• y: Day of year
• d: Day
• w: Weekday
• ww: Week
• h: Hour
• n: Minute
• s: Second
• l: Millisecond
number Number of units of datepart to add to date (positive, to get dates in the future;
negative, to get dates in the past)
date Date/time object, in the range 100 AD–9999 AD.