there is a datecal program by perderabo on the forum. Search for that. I havent personally used as I never had a need to so far. But have read thru the forums so many times and all praises for it :). So go ahead and use it. Here is the link
Use the following script to get previous day's date.
#! /usr/bin/ksh
# Get yesterday's date in YYYY-MM-DD format.
# With argument N in range 1..28 gets date N days before.
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
# Subtract offset from day, if it goes below one use 'cal'
# to determine the number of days in the previous month.
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\)\)