Operating System - HP-UX
1755055 Members
2924 Online
108829 Solutions
New Discussion юеВ

calculate date=todate - 2 weeks

 
SOLVED
Go to solution
Kurt Beyers.
Honored Contributor

calculate date=todate - 2 weeks

Hi,

I'm looking for a shell script that gives me the current date minus 2 weeks in the format YYYYMMDD.

The script would have to run finally on AIX 5.1 32bit.

regards,
Kurt
8 REPLIES 8
Cheryl Griffin
Honored Contributor

Re: calculate date=todate - 2 weeks

Maybe you could leverage from Clay's Date Hammer which is legendary here
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x026250011d20d6118ff40090279cd0f9,00.html
"Downtime is a Crime."
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: calculate date=todate - 2 weeks

How about this:

PREV14=$(caljd.sh -y -s $(caljd.sh -p 14))
echo "Date = ${PREV14}"

Invoke as caljd.sh -u for full usage.

Caljd.sh should run on AIX but change the "shebang" to ksh.

If it ain't broke, I can fix that.
Pete Randall
Outstanding Contributor

Re: calculate date=todate - 2 weeks

Clay's "date alarm" must be ringing off the wall by now. Just in case he's unavailable, I'll suggest that his perl version of caljd would probably fit the bill. It's available from Merijn's site: http://www.cmve.net/~merijn/#Contrib


Pete

Pete
John Meissner
Esteemed Contributor

Re: calculate date=todate - 2 weeks

here's a script that I wrote that looks at the logins for the past 2 months... some slight modifications to it will give you what you need.
All paths lead to destiny
Cheryl Griffin
Honored Contributor

Re: calculate date=todate - 2 weeks

Sir Clay!!!
"Downtime is a Crime."
A. Clay Stephenson
Acclaimed Contributor

Re: calculate date=todate - 2 weeks

THe other option is to use the Perl version; all the arguments are exactly the same simply substitute "caljd.pl" for "caljd.sh". THe Perl version even runs on PC (if you've installed freebie ActivePerl so AIX should be duck soup.

If it ain't broke, I can fix that.
Patrick Wallek
Honored Contributor

Re: calculate date=todate - 2 weeks

Have a look for A. Clay Stephenson's caljd.sh or caljd.pl scripts. The caljd.pl should run fine on AIX if you have Perl installed. The caljd.sh may have to be slightly modified, but it should still run.

http://www.cmve.net/~merijn/caljd.pl

http://www.cmve.net/~merijn/caljd.sh
Kurt Beyers.
Honored Contributor

Re: calculate date=todate - 2 weeks

Thanks a lot for the fast and recursive redirections to the famous caljd.sh script of A. Clay.

Works like a charm on the HPUX 11.0 server here, I'll test it next week on the AIX server (don't have one now to test). But I'm confident that it will work over there as well.

The thread can be closed again ;-)

Kurt