Categories: Date/Time
TIMESTAMPADD
Add (or subtract) an interval of time from a date/timestamp value or column
Syntax
TIMESTAMPADD(unit symbol, count integer, givenTime date or timestamp) → DATE or TIMESTAMP
- unit: The unit of the interval. Must be one of the following: YEAR, QUARTER, MONTH, WEEK, DAY, HOUR, MINUTE, SECOND.
- count: Number of units to be added (or subtracted) from givenTime. To subtract units, pass a negative number.
- givenTime: Value to which to add units (either a database column in DATE or TIMESTAMP format, or literal value explicitly converted to DATE or TIMESTAMP).
Examples
TIMESTAMPADD exampleSELECT timestampadd(day, 1, date '2021-04-01')
-- 2021-04-02
SELECT timestampadd(hour, -2, timestamp '2021-04-01 17:14:32')
-- 2021-04-01 15:14:32
Was this page helpful?
Glad to hear it! Thank you for your feedback.
Sorry to hear that. Thank you for your feedback.