Function to get previous month

Can someone help me creating a function which will give me previous months.

like for example if the date is 200902 and if i call my function and pass a parameter 2 i want to get 200812 as the answer.

or if i pass 200902 with a parameter 7 then my function should give me the date as 200807.

Hi, You can try variants of this basic command:

date --date='2 months ago' +%Y%m

/Lakris