Calculate time difference in SQL / Teradata

visibility 3,516 access_time 3 years ago languageEnglish

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;
info Last modified by Raymond 3 years ago copyright This page is subject to Site terms.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

timeline Stats
Page index 3.38
More from Kontext
Truncate table in Teradata
visibility 1,466
thumb_up 0
access_time 3 years ago
Select top N records in SQL / Teradata
visibility 2,272
thumb_up 0
access_time 2 years ago
Create Table as SELECT - Hive SQL
visibility 5,609
thumb_up 0
access_time 2 years ago