|
|
Archives of the TeradataForum
Message Posted: Fri, 18 Jun 2004 @ 07:40:58 GMT
Subj: | | Re: Calculating Minutes between Timestamps |
|
From: | | Hartman, David L |
Here is a solution -- pretty complicated because of overflow potential -- maybe someone has a better one:
select (case when abs ((end_TS - begin_TS) year(4)) > interval '1' year
then ' 999:00:00.000000'
when abs ((end_TS - begin_TS) month(4)) > interval '1' month
then ' 999:00:00.000000'
else (cast ((((end_TS) - begin_TS) hour(4) to second(6)) as char(18))) end) as timeint,
(substr(timeint,3,3) + (substr(timeint,7,2) / 60) + (substr(timeint,10,2) / 3600)) (decimal(9,2)) as hours,
(hours / 24) (decimal(9,2)) as days,
(hours * 60) (decimal(9,1)) as minutes
| |