Unix Date query

Hi there,

I am trying to do the following in Unix (Solaris 2.7):

1...Find the actual date 7 days ago in format (dd-mmm-yyyy) and with the weekday prefably,

2...Find the date 5 days after the above in the same format.

How can I do this in Unix instead of accessing our Oracle database and doing the date formatting in Oracle instead?

Many thanks for your help,

Chee...

maybe you could give us some more info on what you are doing.

That may help us give you the answer.

Hi there,

Thanks for your email. I thought my original email was pretty clear? Ok anyway, what I would do in unix to get today's date usually I use for filenames, or report headings etc:

echo "`date + %d%m%Y`"

No what would be helpful for me would be to get the date in the above format 7 days ago or however many days I specify to go back or forward.

Can you help?

Many thanks,
Chee...

You could use a script executing this line from CRON everyday.

date > /tmp/date.[1-99]

OR

date > /tmp/date.`date`

I am still puzzled as to why you need the date from several days ago.

:confused:

I have posted several scripts showing how to do date arithmetic in ksh. Use the search function.

I found this from one of the moderators responses to Perderabo.

Not mine but very good!

perl -e 'print scalar localtime(time-86400)'. Gives output of yesterday 24 hours ago.

Just change the 86400 by multiples to go back X number of days.

:smiley: