Get yesterday's date in year-month-day format?

Dear All,

Actually, i'm doing some reporting job and i need to pass yesterday's date in Year-Month-Day format(e.g. 2009-06-10) to another program for generating 2009-06-10 report.

to get today's date, it's easy to just date '+%Y%m%d' , but no idea how can i get this kind of format for yesterday?

echo "`date '+%Y%m%d'` - 1 " | bc seems not the correct way for this, because it will go wrong on the beginning date of each month.
( e.g. 20090601 - 1 will have problem.)

how about converting the date string in '+%s' format back to '+%Y%m%d' format? is this possible? for instance :
echo "`date '+%Y%m%d'` - 86400" | bc | <command to convert back to regular date format probaby by date command> ?
(86400 = 60 seconds * 60 minutes * 24 hours)

any advice on this? I'm sorry if this makes you confusing...

`date -d "1 day ago" +%y%m%d`

thanks so much for this easy way.

by the way, if i just only have the date '%s' format, is it possible to revert it to the regular date format?

for instance : if we receive a time string like this : 1245375232 , how can we know this is actually 2009/6/19 09:33 ??

Thanks.