date -d illegal option in Solaris

Hi All,

Is it possible to run date -d option in Solaris?
Do we have a work around so that -d option will be recognized
by solaris as it is recognized by linux.

I need this since i am using this in scripting and it works in Linux box. my problem is
it doesn't work in solaris box.

QUERY="rpm -qa --queryformat '%{installtime} %{name}-%{version}-%{release}-%{arch} \n'|
awk '{ if ( \$1 > '`date -d "1 week ago" +%s`') print \$2 }'"

Anyone can help me on this please ?

---------- Post updated at 02:46 PM ---------- Previous update was at 02:31 PM ----------

-Or-

Do we have equivalent commands for `date -d "1 week ago" +%s` in Solaris ?

"date" command has only `-u` or `-a` options

You are think of the GNU date implementation. POSIX date does not support those options. GNU unix tools are available as an add-on to Solaris.

one question

how to update system date and time

If you are using a recent enough Solaris release, Gnu date might already be there:

$ uname -a 
SunOS pcjll 5.11 snv_128 i86pc i386 i86pc
$ /usr/gnu/bin/date -d "now -7 days" "+%s"
1258453453

otherwise, you have these nawk and perl solutions:

$ nawk 'BEGIN{print srand()-(7*24*60*60)}'
1258453618
$ perl -e 'printf("%s\n",time-(7*24*60*60));'
1258453627

thanks jigi

Thank guys for all your post..

God Bless you all!