Compare Dates.

Hi All,

I am entering StartDate and EndDate as parameters to script. Want to have an check saying, "If StartDate is greater than EndDate then don't execute the script".

Pseudo Code:

 
if [ "$StartDate" < "$EndDate" ]
then
Execute script
else
exit 0
fi

Can you please help me on the same?

Thanks and Regards
Nagaraja.

What format do you supply the date in? (if it's in epoch that's great, if not you may have to convert to epoch...)

Thanks Skrynesaver for your response..!!

I supply date in DD-MON-YYYY format. I am not aware of using epoc in UNIX. Could you please help me on the same?

Note: Don't want to use perl to achieve this.

Thanks and Regards
Nagaraja.

Convert to YYYYMMDD and compare numerically.

Thanks for your response radoulov..!!

I can convert system date(date) to YYYYMMDD format but not sure how to convert start date and end date to this format. Can you please help on this?

Regards
Nagaraja Akkivalli.