To find previous month last date in Teradata

The following query will help you to find the last day of the previous month.

Syntax:
SELECT ADD_MONTHS(input_date - EXTRACT(DAY FROM input_date), 0 )


How it works ?

First we extract the day from the date and subtracting from the date itself.
So that we are getting the last date of the last month.

input_date - EXTRACT(DAY FROM input_date) ---> last month's end date.

After that we use ADD_MONTHS but not adding any months.
This is to get the proper date output format.

Example:

Consider, date_1 like below

input_date
12/30/2012
02/28/2010
01/12/2011
07/12/2012

SELECT 
input_date,
ADD_MONTHS(input_date - EXTRACT(DAY FROM input_date), 0 )
FROM date_1

Output:
input_dateprev_month_last
12/30/201211/30/2012
02/28/201001/31/2010
01/12/201112/31/2010
07/12/201206/30/2012