Calculate time difference in SQL / Teradata

This code snippet shows how to calculate time differences.

Raymond Tang Raymond Tang 0 6949 3.20 index 7/16/2019

This code snippet shows how to calculate time differences.

DATEDIFF function is not implemented in Teradata. Thus we need to use other approach to calculate time difference.

Code snippet

-- for calculate days difference, we can directly use minus (-) operator
SELECT DATE'2019-07-16' - DATE'2019-06-01' AS Diff_Days;

-- month different
SELECT (DATE'2019-07-16' - DATE'2019-06-01') MONTH(4) AS Diff_Months;
sql teradata

Join the Discussion

View or add your thoughts below

Comments