need a help reg -d in shell

hi,

I am using this to get previous month

`date -d"1 month ago" "+%m"`

But will it work for january?..will it return 12?

Please advice.

date "+%m" | awk '{if($1==01){print 12}else{print $1-1}}'

If I run the following in march I get 12:

% date -d"3 months ago" "+%m"
12

So, I suppose so your command will work for you