Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 18 Jun 2004 @ 07:40:58 GMT


     
  <Prev Next>   <<First <Prev
Next>
Last>>
 


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


     
  <Prev Next>   <<First <Prev
Next>
Last>>
 
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023