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...