Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 21 Apr 2004 @ 11:02:00 GMT


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


Subj:   Re: Seconds to time column conversion
 
From:   Sanjaya Nagabhushan

Hope this helps.

Sanjaya


show table a;

 *** Text of DDL statement returned.
 *** Total elapsed time was 1 second.

---------------------------------------------------------------------------
CREATE SET TABLE TEST.a ,NO FALLBACK ,
     NO BEFORE JOURNAL,
     NO AFTER JOURNAL,
     CHECKSUM = DEFAULT
     (
      i INTEGER)
PRIMARY INDEX ( i );

 BTEQ -- Enter your DBC/SQL request or BTEQ command:

sel*from a;

 *** Query completed. One row found. One column returned.
 *** Total elapsed time was 1 second.

          i
-----------
     359999

 BTEQ -- Enter your DBC/SQL request or BTEQ command:

.width 220
 BTEQ -- Enter your DBC/SQL request or BTEQ command:

sel 'sel cast ((interval '''||trim(i/3600)         ||''' hour  ) as
interval hour to second(0)) +
         cast ((interval '''||trim((i mod 3600)/60)||''' minute) as
interval hour to second(0)) +
         cast ((interval '''||trim(i mod 60)       ||''' second) as
interval hour to second(0)) as HH_MM_SS;' as Query
from a;

 *** Query completed. One row found. One column returned.
 *** Total elapsed time was 1 second.

Query
------------------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------------------
----
sel cast ((interval '99' hour  ) as interval hour to second(0)) +
cast ((interval '59' minute) as interval hour to second(0)) +
cast ((interval '59' second) as interval hour to second(0)) as HH_MM_SS;

 BTEQ -- Enter your DBC/SQL request or BTEQ command:


--Execute the generated query to get the equivalent in HH:MM:SS--


sel cast ((interval '99' hour  ) as interval hour to second(0)) +
cast ((interval '59' minute) as interval hour to second(0)) +
cast ((interval '59' second) as interval hour to second(0)) as HH_MM_SS;


 *** Query completed. One row found. One column returned.
 *** Total elapsed time was 1 second.

   HH_MM_SS
-----------
   99:59:59


     
  <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: 27 Dec 2016