Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 02 Jan 2004 @ 15:48:42 GMT


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


Subj:   Re: ADD_MONTHS
 
From:   Dieter Noeth

Hassinger, Bill wrote:

  Eric, I was giving a general tool for determining the last day of any month. Which is: go to the first day of the subsequent month, and subtract one day. While Dieter's method may be "simpler" in the event of the last day of last month, you can't use it to find the last day of the current month, or the last day of any month but the last month.  


Your algorithm is the right one, but your implementation isn't, too many parentheses ;-)

sel (date '2003-11-30' - (EXTRACT(DAY FROM DATE '2003-11-30')+1))-1;

  *** Query completed. One row found. One column returned.
  *** Total elapsed time was 1 second.

((2003-11-30-(EXTRACT(DAY FROM 2003-11-30)+1))-1)
-------------------------------------------------
                                          03/10/29

sel (date '2003-11-30' - EXTRACT(DAY FROM DATE '2003-11-30')+1)-1;

  *** Query completed. One row found. One column returned.
  *** Total elapsed time was 1 second.

(((2003-11-30-EXTRACT(DAY FROM 2003-11-30))+1)-1)
-------------------------------------------------
                                          03/10/31


     
  <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