Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Mon, 19 Aug 2002 @ 14:11:34 GMT


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


Subj:   Re: Extract Hour from integer column
 
From:   Geoffrey Rommel

  I am using a table time_hist with the column start_time as integer, and has data 11:00:00(inserting using format option). Now i want to extract hour from this column,...  


  You could code it as a substring  


  Select substr(start_time,1,2) from time_hist;  



No! Arithmetic operations are faster and more reliable. Do this:

select start_time / 10000



That's an integer divided by an integer, so it truncates.

Of course the best thing, Rajesh, would be to redefine your table so that start_time is a time(0) rather than an integer, but I'm assuming you can't do that for some reason.



     
  <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