Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subracting Teradata timestamps

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
How can I get the difference between two TeraData timestamps, and return days, hours, or minutes?
 
If the attributes are defind as timestamps, you should be able to do something like:

Select (Timestamp2 - Timestamp1) DAY(4)
From Table1 ;

Change DAY to HOUR or MINUTE for those periods. The (4) is the number of digits in the results, 4 is the max, so for example if the timestamps are 7 days apart, you would get an error deriving Minutes.
 
Hi,
The difference between 2 timestamps is an interval.
This isn't Teradata specific it is ANSI SQL.

You must tell to parser which format you want the answer in.

sel column1 - column2 Day(4) to seconds(6)
from blort;

This means the answer would be the number of Days down to the second difference between the 2 dates.

You can review my note about intervals in....

Thread328-150396


Maybe we should make this a FAQ....

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top