/************************************************
function: CompareDates
Arguments: fromdate : type 'String' : format : DD/MM/YYYY
Arguments: todate : type 'String' : format : DD/MM/YYYY
Returns: Number value
if value = 1 : fromdate comes before todate
if value = 0 : fromdate and todate are same
if value = -1 : fromdate comes after todate
*************************************************/
function CompareDates(fromdate,todate) {
// Assuming the date format = DD/MM/YYYY
// modify following block if your date format is different
// new Date(year,month,day)
frmdt = new Date(fromdate.substring(6,10),fromdate.substring(3,5)-1,fromdate.substring(0,2));
todt = new Date(todate.substring(6,10),todate.substring(3,5)-1,todate.substring(0,2));
if ( todt.getTime() > frmdt.getTime() ) {
return 1;
}
else if( todt.getTime() == frmdt.getTime() ) {
return 0;
}
return -1;
}
Thanks & Regards, Niral Soni