Computing the last day of a month:
Syntax:
- SELECT ADD_MONTHS(( 'input date' - EXTRACT(DAY FROM 'input date') + 1),1)-1;
Example:
If you want to calculate the last day of '2012-06-06'
- SELECT ADD_MONTHS(( '2012-06-06' - EXTRACT(DAY FROM '2012-06-06') + 1),1)-1;
The code above first calculates the first day of the month (Noticed the inner code ?) then add a month to it.
After that it will subtract one day which will yield last day of the month.