Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 31 Dec 2003 @ 17:38:05 GMT


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


Subj:   Re: ADD_MONTHS
 
From:   Eric Williamson

Not exactly Bill- Vinod has a point that the last day(s) of the month are treated slightly differently via Add_Months. But what might be confusing to some is that it only works in one direction - If adding/subtracting a month returns an invalid date (say 11/31), then Teradata returns the actual last day of the month (11/30)...

So ADD_MONTHS(DATE '2003-10-31', -1)
returns 2003-09-30, since 2003-09-31 is invalid.

So ADD_MONTHS(DATE '2003-09-30', -1)
returns 2003-08-30 (not 2003-08-31) since 2003-08-30 IS valid.


So you would not want to use Add_Months if you always want to return the last day-

The method Dieter's suggested is better:
DATE '2003-11-30' - EXTRACT(DAY FROM DATE '2003-11-30')



     
  <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