Updated on 2026-11-06 GMT+08:00

DATE_ADD

Syntax

STRING DATE_ADD(VARCHAR startdate, INT days)
STRING DATE_ADD(TIMESTAMP time, INT days)

Description

The DATE_ADD function is used to return the date after a specified number of days are added to a date. If the target number of days is negative, the corresponding number of days is subtracted.

Parameter Description

  • Date: The data type is TIMESTAMP or STRING (format: yyyy-MM-dd HH:mm:ss). The value can be NULL.
  • Number of days to add: The data type is INT.
  • Return date: The date obtained by adding the specified number of days to the date. The data type is STRING.

Example

CREATE TABLE source (
  time1 TIMESTAMP
) WITH (
  'connector' = 'datagen',
  'rows-per-second' = '1'
);
CREATE TABLE Sink (
  date1 string,
  date2 string,
  date3 string
) with ('connector' = 'print');
INSERT INTO
  Sink
SELECT
  DATE_ADD(time1, 30) as date1,
  DATE_ADD('2017-09-15 00:00:00', 30) as date2,
  DATE_ADD(cast(null as timestamp),30) as date3
FROM source
Table 1 Returned Result

date1 (string)

date2 (string)

date3 (string)

2024-06-28

2017-10-15

null