Thanks for your reply, but can you please explain me what you doing in this script.
My requirment is to pass the date as the parameter and script should return the previous date
I hope its not a late reply mate, i have used such a good script as a part of back up script and it works fine, i hope its usefull for u:
#! /usr/bin/ksh
OFFSET=${1:-1}
case $OFFSET in
*[!0-9]* | ???* | 3? | 29) print -u2 "Invalid input" ; exit 1;;
esac
eval `date "+day=%d; month=%m; year=%Y`
typeset -Z2 day month
typeset -Z4 year
day=$((day - OFFSET))
if (( day <= 0 )) ;then
month=$((month - 1))
if (( month == 0 )) ;then
year=$((year - 1))
month=12
fi
set -A days `cal $month $year`
xday=${days[$(( ${#days[*]}-1 ))]}
day=$((xday + day))
fi