datetime.add()
Adds units of time to a date.
datetime.add( datePart=string, number=number )
Returns: DateTime
| Argument | Description |
|---|---|
|
datePart
string,
required
|
edit
one of the following:
|
|
number
number,
required
|
edit
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. |
Examples
edit datetime = now();
// the below code increments 5 days in actual date
dump(datetime.add("d", 5));
// the below code increments 10 milliseconds in actual date
dump(datetime.add("l", 10));
// the below code increments 60 seconds in actual date
dump(datetime.add("s", 60));
// the below code increments 60 minutes in actual date
dump(datetime.add("n", 60));
// the below code increments 2 hours in actual date
dump(datetime.add("h", 2));
// the below code increments 1 day in actual date
dump(datetime.add("d", 1));
// the below code increments 1 month in actual date
dump(datetime.add("m", 1));
// the below code increments 1 year in actual date
dump(datetime.add("yyyy", 1));