Set_datetime_component
- 18 May 2022
- 1 Minute to read
- DarkLight
- PDF
Set_datetime_component
- Updated on 18 May 2022
- 1 Minute to read
- DarkLight
- PDF
Article Summary
Returns the given datetime with a given component changed to a new value. Valid components are: year
, month
, date
, hour
, minute
, second
or millisecond
.
Note that the value is changed in the timezone in which the given datetime is specified!
Function signature
SET_DATETIME_COMPONENT(date: String, value: Number, component: String) => String
Parameter | Description |
---|---|
Date | Date |
Value | New value for the component |
Component | Component to change |
Examples
Formula | Return value |
---|---|
SET_DATETIME_COMPONENT("2012-07-11T13:06:15+03:00", 2013, "year") | 2013-07-11T13:06:15+03:00 |
SET_DATETIME_COMPONENT("2012-07-11T13:06:15+03:00", 3, "month") | 2012-03-11T13:06:15+03:00 |
SET_DATETIME_COMPONENT("2012-07-11T13:06:15+03:00", 5, "date") | 2012-07-05T13:06:15+03:00 |
SET_DATETIME_COMPONENT("2012-07-11T13:06:15+02:00", 10, "hour") | 2012-07-11T10:06:15+02:00 |
SET_DATETIME_COMPONENT("2012-07-11T13:06:15+01:00", 30, "minute") | 2012-07-11T13:30:15+01:00 |
SET_DATETIME_COMPONENT("2015-12-02T21:45:22.279Z", 12, "millisecond") | 2015-12-02T21:45:22.012Z |
Was this article helpful?