DateAdd Code Examples and CFML Documentation
Adds units of time to a date
The DateAdd function in CFML accepts three parameters: datepart, number, and date. The datepart parameter specifies the unit of time to add to the date, and can be one of the following values:
- year
- month
- day
- week
- hour
- minute
- second
The number parameter specifies the number of units to add to the date. The date parameter specifies the date to which the units will be added.
The DateAdd function returns a datetime object that represents the new date.
Example
<cfset dt = DateAdd("year", 1, "2023-09-01")> In this example, the DateAdd function adds one year to the date "2023-09-01". The resulting datetime object is assigned to the variable dt.
Comments