problem with date

hi friends
I am using AIX 5.2 version
when ever i try to use

echo $(date -d yesterday +"%Y%m%d")

I am getting error as
date: not recognized flag d

please help me solve this.
I wanted to find the next date from a given date.
I tried using diff script but all of them failed at some point or another please help.

check if your date command supports the -d option

thabks for telling me..
but that is not there is there any way to install that

if you wanna find next date in AIX you have to change your TZ variable

fnsonlu1-/home/fnsonlu1/vidya_perl> date
Sun Nov 16 12:02:44 IST 2008
fnsonlu1-/home/fnsonlu1/vidya_perl> echo $TZ
IST-5:30
fnsonlu1-/home/fnsonlu1/vidya_perl> TZ=IST+24
fnsonlu1-/home/fnsonlu1/vidya_perl> date
Sat Nov 15 06:32:58 IST 2008
fnsonlu1-/home/fnsonlu1/vidya_perl> TZ=IST-24
fnsonlu1-/home/fnsonlu1/vidya_perl> date
Mon Nov 17 06:33:07 IST 2008
fnsonlu1-/home/fnsonlu1/vidya_perl> TZ=IST-5:30
fnsonlu1-/home/fnsonlu1/vidya_perl> date
Sun Nov 16 12:03:15 IST 2008

hope this will help you :wink:

The reason is that the "-d" flag is not supported as is clearly stated in the man pages.

If you want to get arbitrary dates either use "datecalc", written by Perderabo or (for very basic calculations) use this simple mechanism:

bakunin@aix52 # echo $(TZ=GMT; date)
Mon Nov 17 09:35:31 GMT 2008
bakunin@aix52 # echo $(TZ=GMT-24; date)
Tue Nov 18 09:35:31 GMT 2008
bakunin@aix52 # echo $(TZ=GMT+48; date)
Sat Nov 15 09:35:31 GMT 2008

I hope this helps.

bakunin

Hi,

You could use the 'date' command from the 'coreutils' package from the AIX toolbox area on IBM's site. (see the AIX links page at the top of the forum). You will need to install RPM aswell.

Then you'll have a date command (/usr/local/bin/date) that will accept the -d parameter. Can be very handy some times!