SUBTRACT_DURATION
Subtract duration from datetime

Description

Returns a new datetime by subtracting a number of given units from the original datetime, such as 1 day or 7 hours.
Valid units are: years, months, dates, hours, minutes, seconds or milliseconds.

Function signature

1
SUBTRACT_DURATION(date: String, duration: Number, units: String = milliseconds) => String
Copied!
Parameter
Description
Date
Date
Duration
Duration to be subtracted from date
Units
Units of duration("years", "months", "weeks", "quarters", "days", "hours", "minutes", "seconds", "milliseconds"). Default is "milliseconds".

Examples

Formula
Return value
SUBTRACT_DURATION("2019-07-11T13:06:15+03:00", 3600000)
2019-07-11T12:06:15+03:00
SUBTRACT_DURATION("2019-07-11T13:06:15+03:00", 1, "hours")
2019-07-11T12:06:15+03:00
SUBTRACT_DURATION("2019-07-11T13:06:15+03:00", 1, "months")
2019-06-11T13:06:15+03:00
SUBTRACT_DURATION("2019-07-11T13:06:15Z", -2, "hours")
2019-07-11T15:06:15Z
Export as PDF
Copy link