Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am getting the following err. when trying to get a date 45 days befo

Status
Not open for further replies.

RajShekar

Programmer
May 27, 2004
14
0
0
US
MONTHDATE(){ # MONTHDATE nDays [format]
typeset -i nDays=$1; format=$2
typeset -i localOffset=$(echo $TZ |
sed 's![^-0-9]*\([-0-9]*\).*!\1!')
TZ=X$((localOffset-24*nDays)) date $format
}
MONTHS_DATE="$(MONTHDATE -45 '+m%d')"

Error:----
It is returning this value where as I am expecting it as YYYYMMDD format...
MONTHS_DATE=m15

Some one please help me.
 
Try this:
MONTHS_DATE="$(MONTHDATE -45 '+%Y%m%d')"

And here an updated version of my faq:
GetDate(){ # GetDate nDays [format]
typeset -i nDays=$1; format=$2
eval $(echo $TZ | sed '
s!\([^-0-9]*\)\([-0-9]*\)\(.*\)!typeset -i localOffset=\2;zon1=\1;zon2=\3!')
TZ=$zon1$((localOffset-24*nDays))$zon2 date $format
}

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top