Help with getting last date of previous month and first date of previous 4th month from current date

I have requirment to get last date of previous month and the first date of previous 4th month:

Example:
Current date: 20130320 (yyyymmdd)
Last date of previous month: 20130228 (yyyymmdd)
First date of previous 4th month: 20121101 (yyyymmdd)

In my shell --date, -d, -v switches are not working for the date command:(

Please help!!:confused:

It's not straight forward in unix..!

If you have a "DB" ( oracle/mysql ) you can do it easily.

Check the below link to see how to do it in perl:

http://stackoverflow.com/questions/9950193/how-can-i-get-the-first-and-last-day-of-the-month-with-perls-datetime

Check this link
http://www.unix.com/answers-frequently-asked-questions/13785-yesterdays-date-date-arithmetic.html

1st of Last Month:

ksh -c  'printf "%(%Y-%m-%d)T\n" "1st last month"'

Last of Previous Month:

ksh -c  'printf "%(%Y-%m-%d)T\n" "final last month"'

1st of Previous Month:

ksh -c  'printf "%(%Y-%m-%d)T\n" "1st last month"'

Last of Previous Month:

ksh -c  'printf "%(%Y-%m-%d)T\n" "final last 1 month "'

1st of two Months from today's Month:

ksh -c  'printf "%(%Y-%m-%d)T\n" "1st last 2 month  "'

Last of two months from today's date:

ksh -c  'printf "%(%Y-%m-%d)T\n" "final last 2 month "'

and so on....