Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Sat, 13 Apr 2013 @ 16:39:33 GMT


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


Subj:   Getting TIME from TIMESTAMP
 
From:   Sukul Mahadik

I wish to extract TIME portion from the TIMESTAMP.

Some book I read says the following syntax should work : SELECT CAST(CURRENT_TIMESTAMP AS TIME);

However this does not work on my system .

Hence I created a ungly looking query to extract Time from timestamp.

     SELECT

     CAST (CASE
              WHEN EXTRACT(HOUR FROM CURRENT_TIMESTAMP) > 9
              THEN  TRIM(EXTRACT(HOUR FROM CURRENT_TIMESTAMP) )
              ELSE '0'||TRIM(EXTRACT(HOUR FROM      CURRENT_TIMESTAMP) )
              END
     ||':'||
     CASE
        WHEN EXTRACT(MINUTE FROM CURRENT_TIMESTAMP) > 9
        THEN  TRIM(EXTRACT(MINUTE FROM CURRENT_TIMESTAMP) )
        ELSE '0'||TRIM(EXTRACT(MINUTE FROM      CURRENT_TIMESTAMP) )
        END
     ||':'||
     TRIM(EXTRACT(SECOND FROM CURRENT_TIMESTAMP)) AS TIME )

Does any body have a simpler looking SQL for extracting Time from timestamp?


Thanks

Sukul Mahadik



     
  <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