Available in versions: Dev (3.20) | Latest (3.19) | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11 | 3.10

DATEADD

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

Add an interval of type java.lang.Number (number of days) or org.jooq.types.Interval (SQL interval type) to a date (represented by java.sql.Date).

SELECT DATE '2020-02-03' + 3;
create.select(dateAdd(Date.valueOf("2020-02-03"), 3)).fetch();

The result being

+------------+
| date_add   |
+------------+
| 2020-02-06 |
+------------+

Dialect support

This example using jOOQ:

dateAdd(Date.valueOf("2020-02-03"), 3)

Translates to the following dialect specific expressions:

Access

dateadd('d', 3, #2020/02/03#)

ASE, Sybase

dateadd(DAY, 3, '2020-02-03')

Aurora MySQL, MariaDB, MySQL

date_add(DATE '2020-02-03', INTERVAL 3 DAY)

Aurora Postgres, ClickHouse, CockroachDB, Exasol, H2, Oracle, Postgres, Redshift, Vertica, YugabyteDB

(DATE '2020-02-03' + 3)

BigQuery

timestamp_add(DATE '2020-02-03', INTERVAL 3 DAY)

DB2, HSQLDB

(DATE '2020-02-03' + (3) day)

Derby

CAST({fn timestampadd(SQL_TSI_DAY, 3, DATE('2020-02-03')) } AS DATE)

DuckDB

CAST(date_add(DATE '2020-02-03', INTERVAL 1 DAY * 3) AS DATE)

Firebird, Snowflake

dateadd(DAY, 3, DATE '2020-02-03')

Hana

add_days(DATE '2020-02-03', 3)

Informix

(DATETIME(2020-02-03) YEAR TO DAY + 3 UNITS DAY)

MemSQL

date_add({d '2020-02-03'}, INTERVAL 3 DAY)

SQLDataWarehouse, SQLServer

dateadd(DAY, 3, CAST('2020-02-03' AS date))

SQLite

strftime('%Y-%m-%d %H:%M:%f', '2020-02-03', (CAST(3 AS varchar) || ' day'))

Teradata

DATE '2020-02-03' + CAST(3 || ' 00:00:00' AS INTERVAL DAY TO SECOND)

Trino

date_add('day', 3, DATE '2020-02-03')
Generated with jOOQ 3.20. Translate your own SQL on our website

References to this page

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo