Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 03 Jan 2006 @ 15:30:39 GMT


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


Subj:   Re: CEIL & Least function in TD
 
From:   Geoffrey Rommel

  I have a command in Oracle  


          > CEIL(LEAST(TO_DATE('31-DEC-2005','DD-MON-YYYY'),SYSDATE) - DUE_DATE)

Actually, this is an expression, not a command. LEAST returns the smallest of its arguments, so it would be equivalent to this case expression:

     case
      when current_date < date '2005-12-31' then current_date
      else date '2005-12-31'
     end

But now this expression will always return '2005-12-31', so you could just hard-code it (unless we're missing some logic).

CEIL returns the next higher integer; for instance, ceil(7.2) is 8. But in Teradata, subtracting a date from a date always returns an integer, so there is no need for the ceiling function. Thus the whole expression becomes:

     (case
      when current_date < date '2005-12-31' then current_date
      else date '2005-12-31'
     end) - due_date


     
  <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