SET_DATETIME_COMPONENT
Set datetime component to new value

Description

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

1
SET_DATETIME_COMPONENT(date: String, value: Number, component: String) => String
Copied!
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
Last modified 2yr ago
Export as PDF
Copy link