All Products
Search
Document Center

Realtime Compute for Apache Flink:DATE_ADD

Last Updated:Aug 30, 2023

This topic describes how to use the DATE_ADD function. This function returns the date after the specified number of days is added to a date.

Limits

This function is supported only in Realtime Compute for Apache Flink that uses Ververica Runtime (VVR) 3.0.0 or later.

Syntax

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

Input parameters

Parameter

Data type

startdate

TIMESTAMP or VARCHAR

Note

A date of the VARCHAR type is in the yyyy-MM-dd or yyyy-MM-dd HH:mm:ss format.

time

TIMESTAMP

days

INT

Note

If an input parameter is NULL or a parsing error occurs, NULL is returned.

Example

  • Test data

    datetime1(VARCHAR)

    nullstr(VARCHAR)

    2017-09-15 00:00:00

    NULL

  • Test statements

    SELECT DATE_ADD(datetime1, 30) as var1,
     DATE_ADD(TIMESTAMP '2017-09-15 23:00:00',30) as var2,
     DATE_ADD(nullstr,30) as var3
    FROM T1;   
  • Test results

    var1(DATE)

    var2(DATE)

    var3(DATE)

    2017-10-15

    2017-10-15

    NULL