DATE_DIFF
Computes the difference between two timestamps.
Syntax
Arguments
UNIT
UNIT
Type: string
The unit of time to return.
It can be one of the following:
year
quarter
month
week
day
hour
minute
second
millisecond
TIMESTAMP1
TIMESTAMP1
Type: timestamp
The time to subtract from TIMESTAMP2
.
TIMESTAMP2
TIMESTAMP2
Type: timestamp
The time TIMESTAMP1
is subtracted from.
Returns
Type: bigint
TIME2 - TIME1
expressed in terms of UNIT
.
Examples
UNIT | TIMESTAMP1 | TIMESTAMP2 | Output |
---|---|---|---|
day |
|
| 1 |
year |
|
| 5 |
year |
|
| -5 |
second |
|
| 30 |
quarter |
|
| 1 |
quarter |
|
| 0 |
year |
|
|
|
Transformation job example
SQL
Query result
$event_timestamp | $commit_time | time_diff |
---|---|---|
2022-08-19 20:20:00.000 | 2022-08-19 20:21:00.000 | 60 |
Last updated