Comparing to Date

Hi ,
I need to compare the given date with the system date . can you tell me any way , how to do it.

The given date format is "23-AUG-2008".

I need to compare it with the system time , i have got the system time in the same format by using the command "date +%e-%b-%y" ,its giving the date as "23-Aug-2008".

I'm nt getting the desired output. Can anyone help me out.
I'm using the following piece of code

variable="23-AUG-08"
variable2=`date +%e-%b-%y`
if [ $variable2 \< $variable ]
then
echo "worked"

    else
                    echo "didnot "

fi

Is this piece of code correct ??? or there is another way to do it ????

try

variable2=`date +%e-%b-%y | tr -s '[:lower:]' '[:upper:]'`

to change to uppercase

In general comparing dates like that will not work, search the forums for 'comparing dates'

You can use the format YYYYMMDD to compare the date:

variable="20080823"
variable2=`date "+%Y%m%d"`
if [ $variable2 \< $variable ]

Regards

Thank you both , i used the command to make them to Uppercase , and now my problem is solved.

Thanks alot :slight_smile: