Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 27 Feb 2003 @ 21:00:31 GMT


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


Subj:   Re: Finding the last day of the month
 
From:   Dieter Nöth

Hayes, Jim M wrote:

  I have a need to find the last day of a month programatically (i.e. hardcoding Jan 31, etc. seems to me to be a kludge).  


  I have the month/year and can append 01 to generate the first day of the next month thusly:  


  ADD_MONTHS('2002-01-01',1)...... results in 2002-02-0 1.  


  Now, I want to subtract 1 day from that date and come up with 2002-01-31. How do I do that?  



ADD_MONTHS('2002-01-01',1) -1

or for any date:

select
add_months(calendar_date, 1)
- extract(day from add_months(calendar_date, 1));


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: 27 Dec 2016