UPDATE_DATE

The function UPDATE_DATE replaces the date described by a DateTime with another specified Date.

This function takes two pieces of input: a base DateTime, and a Date. It outputs a DateTime: the base DateTime but with the date replaced by the information given by the input Date.

Declaration

UPDATE_DATE(base_datetime, new_date) -> new_datetime

Parameters

base_datetime (type: DateTime)
Any DateTime.

new_date (type: Date)
Any Date.
This is what will replace the date information in the given DateTime.

Return Values

new_datetime (type: DateTime)
The DateTime that results from taking the base DateTime and replacing the date with the one given by new_date.

Examples

Assume the example has access to the following DateTime and Date values:

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

The following example takes the DateTime example_date_and_time, which describes a time on April 1st 2020, and replaces the date with the information given by example_date, which describes the date January 2nd, 2022. Note that the resulting DateTime describes the same time, in the same timezone, as did example_date_and_time. Only the date has changed:

UPDATE_DATE(example_date_and_time, example_date) = {  
 "date": {  
  "day": 2,  
  "month": 1,  
  "year": 2022  
 },  
 "time": {  
  "hour": 16,  
  "minute": 14,  
  "second": 38,  
  "millisecond": 0  
 },  
 "timeZone": "UTC"  
}