Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 11 Apr 2013 @ 15:57:38 GMT


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


Subj:   Re: Time addition issue
 
From:   Dieter Noeth

Sukul Mahadik wrote:

  However why can't we perform addition operation as follows  


  select (TIME '12:12:12' + TIME '03:03:03') HOUR;-? Fails  


  Am I doing something that is illogical?  


Yes :-)

You can't add two times: What is 2 o'clock plus 3 o'clock?

You have to add a duration of time to a time, i.e. an INTERVAL. A TIME and an INTERVAL HOUR TO SECOND look exactly the same, but are different.

This will work:

     TIME '12:12:12' + interval '03:03:03' hour to second

To change a TIME to an Interval you simply substract midnight:

     TIME '12:12:12' - TIME '00:00:00' HOUR TO SECOND

     select TIME '12:12:12' + (TIME '12:12:12' - TIME '00:00:00' HOUR TO SECOND);

Dieter



     
  <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