I need to get the date one month in the future from today - or 30 days from today etc...
I need this to work all year around - I cannot find anything to solve this issue in the search / faqs etc....
I need to get the date one month in the future from today - or 30 days from today etc...
I need this to work all year around - I cannot find anything to solve this issue in the search / faqs etc....
Its okay - just found I can use something like the below
curmth=`date +%m`
set -A mth 01 02 03 04 05 06 07 08 09 10 11 12
nextmth=${mth[$((curmth))]}
echo $nextmth
curday=`date +%d`
curyear=`date +%Y`
todaynextmonth=$curyear$nextmth$curday
echo "todaynextmonth is $todaynextmonth"
Your script doesn't work in December.
Did you actually look in the FAQ section? http://www.unix.com/answers-frequently-asked-questions/13785-yesterdays-date-date-arithmetic.html
try this this will give you exact 30 days future date from todays date
fnsonlq0-/home/fnsonlq0>date
Fri Aug 15 15:44:59 IST 2008
fnsonlq0-/home/fnsonlq0>TZ=IST-720
fnsonlq0-/home/fnsonlq0>date
Sun Sep 14 10:15:06 IST 2008
fnsonlq0-/home/fnsonlq0>TZ=IST-5:30
fnsonlq0-/home/fnsonlq0>date
Fri Aug 15 15:45:11 IST 2008
Using the --date option lets You chose how You want it
date --date='1 month'
date --date='10 days ago'
/Lakris
hi Lakris i don't think all unix has that --date option
because AIX don't have any such option...