DATE_ADD function in Amazon QLDB - Amazon Quantum Ledger Database (Amazon QLDB)

DATE_ADD function in Amazon QLDB

Important

End of support notice: Existing customers will be able to use Amazon QLDB until end of support on 07/31/2025. For more details, see Migrate an Amazon QLDB Ledger to Amazon Aurora PostgreSQL.

In Amazon QLDB, use the DATE_ADD function to increment a given timestamp value by a specified interval.

Syntax

DATE_ADD( datetimepart, interval, timestamp )

Arguments

datetimepart

The date or time part that the function operates on. This parameter can be one of the following:

  • year

  • month

  • day

  • hour

  • minute

  • second

interval

The integer that specifies the interval to add to the given timestamp. A negative integer subtracts the interval.

timestamp

The field name or expression of data type timestamp that the function increments.

An Ion timestamp literal value can be denoted with backticks (`...`). For formatting details and examples of timestamp values, see Timestamps in the Amazon Ion specification document.

Return type

timestamp

Examples

DATE_ADD(year, 5, `2010-01-01T`) -- 2015-01-01T DATE_ADD(month, 1, `2010T`) -- 2010-02T (result adds precision as necessary) DATE_ADD(month, 13, `2010T`) -- 2011-02T (2010T is equivalent to 2010-01-01T00:00:00.000Z) DATE_ADD(day, -1, `2017-01-10T`) -- 2017-01-09T DATE_ADD(hour, 1, `2017T`) -- 2017-01-01T01:00Z DATE_ADD(hour, 1, `2017-01-02T03:04Z`) -- 2017-01-02T04:04Z DATE_ADD(minute, 1, `2017-01-02T03:04:05.006Z`) -- 2017-01-02T03:05:05.006Z DATE_ADD(second, 1, `2017-01-02T03:04:05.006Z`) -- 2017-01-02T03:04:06.006Z -- Runnable statements SELECT DATE_ADD(year, 5, `2010-01-01T`) FROM << 0 >> -- 2015-01-01T SELECT DATE_ADD(day, -1, `2017-01-10T`) FROM << 0 >> -- 2017-01-09T

Related functions