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 | date1 (string) | date2 (string) | date3 (string) |
|---|---|---|
| 2024-06-28 | 2017-10-15 | null |
Parent topic: Enhanced Functions
What is your overall rating for this page?
0
1
2
3
4
5
6
7
8
9
10
Very dissatisfiedVery satisfied
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot