DATE_ADD
Adds an interval of a specified unit to a given timestamp. Subtraction can be performed by using a negative interval value.
Syntax
Arguments
UNIT
UNIT
Type: string
The unit of time to add.
It can be one of the following:
year
quarter
month
week
day
hour
minute
second
millisecond
VALUE
VALUE
Type: bigint
The integer value of the UNIT
to add to TIMESTAMP
.
Can be positive (for times in the future) or negative (for times in the past).
TIMESTAMP
TIMESTAMP
Type: timestamp
The timestamp to be modified.
Returns
Type: timestamp
The TIMESTAMP
with an INTERVAL
of the given NUMBER
added to it.
Examples
UNIT | VALUE | TIMESTAMP | Output |
---|---|---|---|
day | 1 |
|
|
year | 5 |
|
|
second | 30 |
|
|
quarter | 1 |
|
|
quarter | -1 |
|
|
quarter | 0 |
|
|
year | 1 |
|
|
Transformation job example
SQL
Query result
$event_timestamp | day_after | day_before |
---|---|---|
2022-08-19 20:11:00.000 | 2022-08-20 20:11:00.000 | 2022-08-18 20:11:00.000 |
Last updated