|  |  | Archives of the TeradataForumMessage Posted: Thu, 27 Feb 2003 @ 21:00:31 GMT
 
 
  
| 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: selectadd_months(calendar_date, 1)
 - extract(day from add_months(calendar_date, 1));
 
 Dieter 
 
 |  |