Date format - Shell scripting gurus please help

Guys:
I have the following script (from this forum) to calculate yesterdays date.
However the format of the date that is output is yyyymd if the resultant date is single digit or the resultant month is a single digit month ( 01 - 09 ). How can I get the output to show the date in the following format yyyymmdd always instead of yyyymd

Below is the script:
date '+%Y %m %d' |#echo here shows date in the yyyymmdd format
{
read YEAR MONTH DAY #echo here shows date in the yyyymmdd format
DAY1=`expr "$DAY" - 1`
case "$DAY1" in
0)
MONTH=`expr "$MONTH" - 1`
echo $MONTH
case "$MONTH" in
0)
MONTH=12
YEAR=`expr "$YEAR" - 1`
;;
esac
DAY1=`cal $MONTH $YEAR | grep . | fmt -1 | tail -1`
DAY2=`expr "$DAY1" - 1`
echo $DAY1 # shows date in yyyymdd format if DAY1 is 200612 instead of 20060102
echo $DAY2 # shows date in yyyymdd format if DAY2 is 200611 instead of 20060101
esac
}

regards, m

Add a little if condition before you expr to check if the resulting date is between 1 -9 and if it is then add a 0 as prefix of the $DAY variable

In ksh,
typeset -Z2 MONTH DAY

Hi ,
have u used following command

date -d "yesterday" '+%Y%m%d'