Obtaining day before a given date

Hi all,

is there a way using GNU (Solaris 8) methods of obtaining the day before a given day?

i.e. 2007-09-09.... I would like the date a day before it so output would be 2007-09-08. Format YYYY-MM-DD

I know I can subtract the day number using cut and expr but it would get tricky if the date was 2007-09-01 for example and would also make my script long with all the permutations of checking months, years etc.

$ date -d '2007-09-09 1 day ago' +'%F'
2007-09-08
$

Jean-Pierre.

Thanks Jean-Pierre but i am afraid i cannot use the -d option.

I get the following:

date: illegal option -- d
usage: date [-u] mmddHHMM[[cc]yy][.SS]
date [-u] [+format]
date -a [-]sss[.fff]

-d (or --date) is an option that is specific to the GNU version of date.

Seems that you don't use GNU commands.
In that case, consult the post Yesterdays Date/Date Arithmetic

Jean-Pierre.