Calculate time difference in SQL / Teradata

access_time 2 years ago visibility677 comment 0

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 at 2 years ago copyright This page is subject to Site terms.
Like this article?
Share on

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

Kontext Column

Created for everyone to publish data, programming and cloud related articles.
Follow three steps to create your columns.


Learn more arrow_forward

More from Kontext

local_offer teradata local_offer SQL

visibility 648
thumb_up 1
access_time 10 months ago

This code snippet shows how to convert string to date in Teradata.

local_offer teradata local_offer python local_offer Java local_offer python-database

visibility 944
thumb_up 0
access_time 6 months ago

Python JayDeBeApi module allows you to connect from Python to Teradata databases using Java JDBC drivers. In article Connect to Teradata database through Python , I showed how to use teradata package to connect to Teradata via Teradata ODBC driver. This article demos how to use this JayDeBeApi ...

local_offer teradata local_offer SQL local_offer teradata-functions

visibility 100
thumb_up 0
access_time 2 months ago

This page shows how to trim or remove leading or/and trailing zeros using Teradata SQL.

About column

Code snippets

Code snippets for various programming languages/frameworks.

rss_feed Subscribe RSS