Set_datetime_component
  • 18 May 2022
  • 1 Minute to read
  • Dark
    Light
  • PDF

Set_datetime_component

  • Dark
    Light
  • 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
ParameterDescription
DateDate
ValueNew value for the component
ComponentComponent to change

Examples

FormulaReturn 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?

What's Next