# DateAdd

Modifies a date object by date part and integer time unit

## Method Signature

```
DateAdd(datepart=[string], number=[number], date=[any])
```

### Arguments

| Argument   | Type     | Required | Description                      | Default |
| ---------- | -------- | -------- | -------------------------------- | ------- |
| `datepart` | `string` | `true`   | The date part to modify          |         |
| `number`   | `number` | `true`   | The number of units to modify by |         |
| `date`     | `any`    | `true`   | The date object to modify        |         |

## Examples

### Add Days to a Date

Add 30 days to August 3rd, 2014.

[Run Example](https://try.boxlang.io/?code=eJxLSSxJdUxJ0VBQSlHSUTA20FFQstA31jcyMDRRUtC05gIAhqsG9Q%3D%3D)

```java
dateAdd( "d", 30, "8/3/2014" );

```

Result: {ts '2014-04-07 00:00:00'}

### Subtract Days from a Date

Subtract 30 days from August 3rd, 2014.

[Run Example](https://try.boxlang.io/?code=eJxLSSxJdUxJ0VBQSlHSUdA1NtBRULLQN9Y3MjA0UVLQtOYCAI3mByI%3D)

```java
dateAdd( "d", -30, "8/3/2014" );

```

Result: {ts '2014-02-06 00:00:00'}

### Add Weeks to a Date

Here we're adding 8 weeks to the date August 3rd, 2014.

[Run Example](https://try.boxlang.io/?code=eJxLSSxJdUxJ0VBQKi9X0lGw0FFQstA31jcyMDRRUtC05gIAjpQHVA%3D%3D)

```java
dateAdd( "ww", 8, "8/3/2014" );

```

Result: {ts '2014-05-03 00:00:00'}

### Add Days to a Date (Member Function)

Here we're adding 1 day to the current date/time.

[Run Example](https://try.boxlang.io/?code=eJxLLkpNLEl1AWINBSMDIyMdBUMDIFbQ1EtMSdFQUEpRAvOsuQDtZQnG)

```java
createDate( 2022, 10, 1 ).add( "d", 1 );

```

Result: {ts '2022-10-02 00:00:00'}

### Additional Examples

[Run Example](https://try.boxlang.io/?code=eJyV0LsKwzAMBdA9XyEyuRDIY8jSqZ%2FiWgIbbLn4QcjfV%2B1aqGNpEVzuGTTPUCzBk3w8wEQkcGwSBeKSYV0gOO9dJhMZs0SgTanaA%2BpCA9bwUt%2Fzgahg9OMklQk4HuoGsvdh%2FsfvC1yUs8h7nxwc10JNmTvlDWysqclaYbfr6irVs2Xi5709ZohcbEsNvepJOrXQU%2BbHfQOok8Hu)

```java
// 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() ) );

```

## Related

* [ClearTimezone](/boxlang-language/reference/built-in-functions/temporal/cleartimezone.md)
* [CreateDate](/boxlang-language/reference/built-in-functions/temporal/createdate.md)
* [CreateDateTime](/boxlang-language/reference/built-in-functions/temporal/createdatetime.md)
* [CreateODBCDate](/boxlang-language/reference/built-in-functions/temporal/createodbcdate.md)
* [CreateODBCDateTime](/boxlang-language/reference/built-in-functions/temporal/createodbcdatetime.md)
* [CreateODBCTime](/boxlang-language/reference/built-in-functions/temporal/createodbctime.md)
* [CreateTime](/boxlang-language/reference/built-in-functions/temporal/createtime.md)
* [CreateTimeSpan](/boxlang-language/reference/built-in-functions/temporal/createtimespan.md)
* [DateCompare](/boxlang-language/reference/built-in-functions/temporal/datecompare.md)
* [DateConvert](/boxlang-language/reference/built-in-functions/temporal/dateconvert.md)
* [DateDiff](/boxlang-language/reference/built-in-functions/temporal/datediff.md)
* [DateFormat](/boxlang-language/reference/built-in-functions/temporal/dateformat.md)
* [DatePart](/boxlang-language/reference/built-in-functions/temporal/datepart.md)
* [DateTimeFormat](/boxlang-language/reference/built-in-functions/temporal/datetimeformat.md)
* [Day](/boxlang-language/reference/built-in-functions/temporal/day.md)
* [DayOfWeek](/boxlang-language/reference/built-in-functions/temporal/dayofweek.md)
* [DayOfWeekAsString](/boxlang-language/reference/built-in-functions/temporal/dayofweekasstring.md)
* [DayOfWeekShortAsString](/boxlang-language/reference/built-in-functions/temporal/dayofweekshortasstring.md)
* [DayOfYear](/boxlang-language/reference/built-in-functions/temporal/dayofyear.md)
* [DaysInMonth](/boxlang-language/reference/built-in-functions/temporal/daysinmonth.md)
* [DaysInYear](/boxlang-language/reference/built-in-functions/temporal/daysinyear.md)
* [FirstDayOfMonth](/boxlang-language/reference/built-in-functions/temporal/firstdayofmonth.md)
* [GetNumericDate](/boxlang-language/reference/built-in-functions/temporal/getnumericdate.md)
* [GetTime](/boxlang-language/reference/built-in-functions/temporal/gettime.md)
* [GetTimezone](/boxlang-language/reference/built-in-functions/temporal/gettimezone.md)
* [GetTimezoneInfo](/boxlang-language/reference/built-in-functions/temporal/gettimezoneinfo.md)
* [Hour](/boxlang-language/reference/built-in-functions/temporal/hour.md)
* [Millisecond](/boxlang-language/reference/built-in-functions/temporal/millisecond.md)
* [Minute](/boxlang-language/reference/built-in-functions/temporal/minute.md)
* [Month](/boxlang-language/reference/built-in-functions/temporal/month.md)
* [MonthAsString](/boxlang-language/reference/built-in-functions/temporal/monthasstring.md)
* [MonthShortAsString](/boxlang-language/reference/built-in-functions/temporal/monthshortasstring.md)
* [Nanosecond](/boxlang-language/reference/built-in-functions/temporal/nanosecond.md)
* [Now](/boxlang-language/reference/built-in-functions/temporal/now.md)
* [Offset](/boxlang-language/reference/built-in-functions/temporal/offset.md)
* [ParseDateTime](/boxlang-language/reference/built-in-functions/temporal/parsedatetime.md)
* [Quarter](/boxlang-language/reference/built-in-functions/temporal/quarter.md)
* [Second](/boxlang-language/reference/built-in-functions/temporal/second.md)
* [SetTimezone](/boxlang-language/reference/built-in-functions/temporal/settimezone.md)
* [TimeFormat](/boxlang-language/reference/built-in-functions/temporal/timeformat.md)
* [TimeUnits](/boxlang-language/reference/built-in-functions/temporal/timeunits.md)
* [Week](/boxlang-language/reference/built-in-functions/temporal/week.md)
* [Year](/boxlang-language/reference/built-in-functions/temporal/year.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/temporal/dateadd.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
