1753800 Members
7948 Online
108805 Solutions
New Discussion юеВ

Date one week from today

 
SOLVED
Go to solution

Date one week from today

Hello experts,

Is there a way to print the date one week from the current date in the form "16-January-2003". I can't seem to make the date command do anything but the current date.

Thanks in advance for any help,
Steve
6 REPLIES 6
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Date one week from today

Actually this is quite easy with the date (now where's your nail?) hammer, caljd.sh.

DT7=$(caljd.sh -O -e -S "-" $(caljd.sh -n 7))
echo "Date: ${DT7}"

Invoke caljd.sh -u for full usage.




If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: Date one week from today

If you had rather use Perl then here's caljd.pl; the arguments are identical.

If it ain't broke, I can fix that.
Jose Mosquera
Honored Contributor

Re: Date one week from today

Hi,

#date +%d-%M-%Y


I'm not sure about month a year format, but use "man date" to review date options and correct them.


Rgds.


Re: Date one week from today

Hi A. Clay,

You script worked great. I also needed to output the month names in Spanish so I made a copy of your script and found where you defined the months and changed it. It works great too.

Jose,

I still could get date to work on anything but today's date.


Thanks again,
Steve
A. Clay Stephenson
Acclaimed Contributor

Re: Date one week from today

Steve, Steve, Steve, ...

You didn't need to make a copy
of caljd.sh to make it habla espanol. Did you bother to do a caljd.sh -u? All you needed to do was set and export LANG to enable NLS support.


export LANG=es_ES.iso88591 SP_DT7=$(caljd.sh -O -e -S "-" $(caljd.sh -n 7))
echo "Date: ${SP_DT7}"


Do a locale -a to list all available locales.

If it ain't broke, I can fix that.

Re: Date one week from today

Hi A. Clay,

You sure know how to make a guy feel stupid. I promise I will read the usage messages from now on!!

Thanks again,
Steve