How to compare two different dates in dd/mm/yyyy format
<p>Can anyone help me in finding the solution</p>

<p>i just want to compare two dates in dd/mm/yyyy format.</p>

<pre><code>function compareDate(dt1 , dt2 , formatString){var returnVal = 2;
    var dt1Parts;
    var dt2Parts;
    var dt1dd;
    var dt1mm;
    var dt1yyyy;
    var dt2dd;
    var dt2mm;
    var dt2yyyy;
    if(formatString == 'dd/mm/yyyy'){
        dt1Parts = dt1.split('/');
        dt2Parts = dt2.split('/');
        dt1dd = parseInt(dt1Parts[0]);
        dt1mm = parseInt(dt1Parts[1]);
        dt1yyyy = parseInt(dt1Parts[2]);
        dt2dd = parseInt(dt2Parts[0]);
        dt2mm = parseInt(dt2Parts[1]);
        dt2yyyy = parseInt(dt2Parts[2]);
    }
    else if(formatString == 'dd-mm-yyyy'){
        dt1Parts = dt1.split('-');
        dt2Parts = dt2.split('-');
        dt1dd = parseInt(dt1Parts[0]);
        dt1mm = parseInt(dt1Parts[1]);
        dt1yyyy = parseInt(dt1Parts[2]);
        dt2dd = parseInt(dt2Parts[0]);
        dt2mm = parseInt(dt2Parts[1]);
        dt2yyyy = parseInt(dt2Parts[2]);
    }else{
        alert(formatString+' format is not supported.');
    }
    if(dt1yyyy == dt2yyyy &amp;&amp; dt1mm == dt2mm &amp;&amp; dt1dd == dt2dd){
        returnVal = 0;
    }
    else if(dt1yyyy &gt; dt2yyyy){
        returnVal = 1 ;
    }else if(dt1yyyy == dt2yyyy ){
        if(dt1mm &gt; dt2mm){
            returnVal = 1;
        }else if(dt1mm == dt2mm){
            if(dt1dd &gt; dt2dd){
                returnVal = 1;
            }else{
                returnVal = -1;
            }
        }else{
            returnVal = -1;
        }
    }else{
        returnVal = -1;
    }
    return returnVal;
}
</code></pre>

<p>Thanks in advance,
Shilpa</p>
