Calculate time difference in SQL / Teradata

event 2019-11-18 visibility 6,648 comment 0 insights
more_vert
insights Stats
Raymond Raymond Code Snippets & Tips

Code snippets and tips for various programming languages/frameworks. All code examples are under MIT or Apache 2.0 license unless specified otherwise. 

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;
More from Kontext
comment Comments
No comments yet.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts