Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 02 Nov 2012 @ 20:57:11 GMT


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


Subj:   Re: Subtraction between dates
 
From:   Curley, David

That's because you're doing number math, not date math.

Teradata converts the strings in that SQL to numbers, not dates, so it sees your query as "Select 20120220 - 20120210" and returns 10.

In your second query, try making the two dates in different years and you'll get a very different answer.

Select cast('2012-03-10' as date) - cast('2012-02-05' as date) will give you what you expect.

Same thing for subtracting x days:

     select '2012/02/20' -45
     20120175.00

     select cast('2012/02/20' as date) - 45
     01/06/2012


     
  <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