DateAdd()
Adds units of time to a date object.
DateAdd( datePart=string, number=number, date=datetime );
Returns: DateTime
Argument | Description |
---|---|
datePart
string,
required
|
One of the following units:
|
number
number,
required
|
Number of units of datepart to add to date (positive, to get dates in the future; negative, to get dates in the past). Number must be an integer. |
date
datetime,
required
|
date object; for example, now() |
Examples
// the below code increments 10 milliseconds in actual date
dump(dateAdd("l", 10, now()));
// the below code increments 60 seconds in actual date
dump(dateAdd("s", 60, now()));
// the below code increments 60 minutes in actual date
dump(dateAdd("n", 60, now()));
// the below code increments 2 hours in actual date
dump(dateAdd("h", 2, now()));
// the below code increments 1 day in actual date
dump(dateAdd("d", 1, now()));
// the below code increments 1 month in actual date
dump(dateAdd("m", 1, now()));
// the below code increments 1 year in actual date
dump(dateAdd("yyyy", 1, now()));
See also
- Date and time
- datetime.add()
- Search Issue Tracker
- Search Lucee Test Cases (good for further, detailed examples)