Hello Team, Whats the equivalent to date_diff(unit...
# general
p
Hello Team, Whats the equivalent to date_diff(unit, t1, t2) function in pinot
Copy code
DATETIMECONVERT(DATETRUNC(millis, t1) - DATETRUNC(millis, t2), '1:MILLISECONDS:EPOCH', '1:<unit>:EPOCH')
?
m
Yes, above would achieve the equivalent of date_diff.
@Parag Jain I stand corrected, there's
timestampdiff
already in Pinot. For example: I can run this in quicstart:
select timestampdiff(second, 100000000, 200000000)  from airlineStats
There is also
datediff
Here are the examples:
select timestampDiff(second, 100000000, 200000000)  from airlineStats
select datediff('second', 100000000, 200000000)  from airlineStats
Note, the first arg in
datediff
has to be quoted for it to be treated as literal. This is because
timestampdiff
is a SQL keyword, but
datediff
is not.
p
Thanks, I could not find it in the docs. Would be great to update the docs.