Hi,
COuld you pleas ehelp me how to get the 3rd last month's 1st date and 2nd last month of the last date through script.
Ex : - If today is the "1-Feb-2010" then I need the output like
Today is ---> 1-Feb-2010
First day of the 3rd last month --> 1-Nov-2009.
Last day of the 2nd last month --> 31-Dec-2009.
**************************************
I have written a script in the below format but it is failing in whenthe month is 1 (jan) and 3 (March).
Please help me.
day=1
month=01
year=2010
echo "Today is ---> "$day'-'$month'-'$year
lmonth=`expr $month - 2`
if test "$lmonth" = "0"
then
lmonth=12
year=`expr $year - 1`
fi
v_3rd_last_month=`expr $lmonth - 1`
lday=`cal $lmonth $year |awk '$0~/[0-9]/ {print $NF}'|tail -1`
echo "First day of the 3rd last month ---> " 01'-'$v_3rd_last_month'-'$year
echo "Last day of 2nd last month was ---> " $lday'-'$lmonth'-'$year
COuld you pleas ehelp me how to get the 3rd last month's 1st date and 2nd last month of the last date through script.
Ex : - If today is the "1-Feb-2010" then I need the output like
Today is ---> 1-Feb-2010
First day of the 3rd last month --> 1-Nov-2009.
Last day of the 2nd last month --> 31-Dec-2009.
**************************************
I have written a script in the below format but it is failing in whenthe month is 1 (jan) and 3 (March).
Please help me.
day=1
month=01
year=2010
echo "Today is ---> "$day'-'$month'-'$year
lmonth=`expr $month - 2`
if test "$lmonth" = "0"
then
lmonth=12
year=`expr $year - 1`
fi
v_3rd_last_month=`expr $lmonth - 1`
lday=`cal $lmonth $year |awk '$0~/[0-9]/ {print $NF}'|tail -1`
echo "First day of the 3rd last month ---> " 01'-'$v_3rd_last_month'-'$year
echo "Last day of 2nd last month was ---> " $lday'-'$lmonth'-'$year