# UPDATE\_DAY

**The function UPDATE\_DAY changes the day described by a Date or DateTime into another specified number.**

This function takes two pieces of input: a [Date](../../variable-data-types/the-date-variable-data-type) or a [DateTime](../../variable-data-types/the-datetime-variable-data-type), and a Number. It outputs the given Date or Datetime with the day value replaced by the given number.

#### Declaration

```javascript
UPDATE_DAY(datetime, new_day) -> new_datetime
```

```javascript
UPDATE_DAY(date, new_day) -> new_date
```

&#x20;

#### Parameters

**datetime** (type: _DateTime_) Any DateTime.

**date** (type: _Date_) Any date.

**new\_day** (required, type: _Number_) The new day; this is the number that will replace whatever value is currently associated with the day in the given Date or DateTime.

#### Return Values

**new\_datetime** (type: _DateTime_) The DateTime that results from taking the given DateTime and replacing the day value with the given number.

**new\_date** (type: _Date_) The Date that results from taking the given Date and replacing the day value with the given number.

#### Examples

Assume the first example has access to the following DateTime value:

```javascript
example_date_and_time = {  
 "date": {  
  "day": 1,  
  "month": 4,  
  "year": 2021  
 },  
 "time": {  
  "hour": 16,  
  "minute": 14,  
  "second": 38,  
  "millisecond": 0  
 },  
 "timeZone": "UTC"  
}
```

The following example takes the date described in **example\_date\_and\_time** and replaces the given day value (1) with 16. Note that the only difference between the output of this example and **example\_date\_and\_time** is the the value of the day. When given a DateTime as input, UPDATE\_DAY returns a DateTime:

```javascript
UPDATE_DAY(example_date_and_time, 16) = {  
 "date": {  
  "day": 16,  
  "month": 4,  
  "year": 2021  
 },  
 "time": {  
  "hour": 16,  
  "minute": 14,  
  "second": 38,  
  "millisecond": 0  
 },  
 "timeZone": "UTC"  
}
```

The above example demonstrates how the UPDATE\_DAY function behaves when given a DateTime as input. In order to further establish how the UPDATE\_DAY function behaves when given a Date as input, assume the last example has access to the following Date value:

```javascript
example_date = {  
 "day": 1,  
 "month": 4,  
 "year": 2021  
}
```

The following example takes the Date described in **example\_date** and replaces the given day value (1) with 16. Note that the only difference between the output of this example and **example\_date** is the the value of the day. When given a Date as input, UPDATE\_DAY outputs a Date:

```javascript
UPDATE_DAY(example_date, 16) = {  
 "day": 16,  
 "month": 4,  
 "year": 2021  
}
```
