Hi ,
I need a function that verfies the given date is between start date and end date .
I have written this but this not working if start date is 1900/01/01
Below is my code
validateDate()
{
RC=$#
if [ $RC -lt "3" ]
then
return 0
else
#echo "Start Date is $START_DATE and End Date is $END_DATE"
dateComp2=`echo $START_DATE $fileDate | awk '$2<$1{print -1;next}{print ($2>$1)}'`
# echo "$START_DATE ==== $fileDate ==== $dateComp2 "
if [ $dateComp2 -ne -1 ]
then
dateComp3=`echo $fileDate $END_DATE | awk '$2<$1{print -1;next}{print ($2>$1)}'`
if [ $dateComp3 -ne -1 ]
then
return 1
else
return 0
fi
else
return 0
fi
fi
}
START_DATE=$1
fileDate=$2
END_DATE=$3
validateDate $1 $2 $3
if [ $? -eq 1 ]
then
echo "present "
elif [ $? -eq 0 ]
then
echo "not present "
fi
the above code is not working for
sh dateValidation.sh 1900/01/01 2009/07/15 2009/07/14
please suggest any modification or alternate function?