1753538 Members
4739 Online
108795 Solutions
New Discussion юеВ

Re: Help on date

 
Rinky
Advisor

Help on date

Hi all,

I need a command or a script which calculates
current date -6.

If today`s date is 01/12/2007,
i need the script to give me output of 25/11/2007.

Please help.
Unix shell script is required..
4 REPLIES 4
A. Clay Stephenson
Acclaimed Contributor

Re: Help on date

Use the attached script, caljd.sh. Then it couldn't be simpler.

DTMINUS6=$(caljd.sh -e -S "/" $(caljd.sh -p 6))
echo "Six days ago in DD/MM/YYYY format is ${DTMINUS6}"


Invoke as caljd.sh -u for many examples and full usage.
If it ain't broke, I can fix that.
Michael D. Zorn
Regular Advisor

Re: Help on date

Clay keeps giving master classes on scriptwriting. Now I've got about a week of study ahead. At the end of which, luckily, I can pare out all that "stupid bash" stuff (I live happily in a Korn shell).

"Then it couldn't be simpler." Brain surgery is simple, too - once you know how to do it.

paolo barila
Valued Contributor

Re: Help on date

I use "date" command from GNU

http://www.gnu.org/software/coreutils

It supports this:

# date --date="6 days ago"


Pablo
share share share
Peter Godron
Honored Contributor

Re: Help on date

perl -e'@d=localtime time-518400;printf"%02d/%02d/%4d\n",$d[3],++$d[4],1900+$d[5]'

as 518400 is 6 days in seconds

Please also read:
http://forums1.itrc.hp.com/service/forums/helptips.do?#33
on how to reward any useful answers given to your questions.

So far you have only awared points to 13 of 29 answers !