Date format script (in .sh)

Could anyone suggest me on how to write unix script for displaying yesterdays date ie. if today is 2nd Mar then when i run .sh script i should get displayed as "01-Mar-2010".

#!/bin/bash

#call with deltaday 'date' 'deltadays'

#there is no error checking, use at your own use...

if [ ! -n "$1" ]
then
  echo "Usage: `basename $0` YYYYMMDD [+-days]"
  exit $E_BADARGS
fi  

if [ ! -n "$2" ]
then
  	deltadays=-1
  else
	deltadays=$2
fi  


epoch=$(date -j -f "%Y%m%d" $1 "+%s")

(( deltadays *= 60*60*24 ))
(( epoch += deltadays )) 

newday=$(date -j -f "%s" $epoch "+%Y%m%d")

echo $newday

This is dependent on the date utility being similar to BSD. It is different on Linux and Solaris...

hmmm.. looks complicated...
i just want to print a date in my subject of a mail sent from the script.

What OS?

Read the man page for date.

Under Linux, it may be as simple as

date -d "yesterday"

ok. that looks much simpler.

my subject is like ABCDEFGHIJ DATE(DD-MON-YY) Format.

its in a shell script which after execution ll mail to an mail id.

Search the forum before posting
http://www.unix.com/answers-frequently-asked-questions/13785-yesterdays-date-date-arithmetic.html