Check if a date is greater than specified date
<p>How can I check that a date is greater than or less than the specified date using javascript by passing the month and year only in <code>MMM-YYYY</code> Format.</p>

<p>For example :</p>

<p>Let the user selects <strong>JUL</strong> from month dropdown and <strong>2016</strong> from years dropdown ,</p>

<p>Now How can I check that the selected values are <strong>greater than / less than</strong> JUN 2016 .</p>

<p>I've taken the input in Session variables as session("month") , session("yrs").</p>

<p>I've tried the following but nothing happens :</p>

<pre><code>var d1 = new Date('JUN-2016')
var d2 = new Date(&lt;% =session("month")+"-"+session("yrs") %&gt;) )
if(d2.getTime() &gt; d2.getTime())
{
alert('Greater than jun 2016');
}
else
{
alert('Less than jun 2016');
}
</code></pre>

<p>I've gone through this link <a href="https://stackoverflow.com/questions/492994/compare-two-dates-with-javascript">Compare two dates with JavaScript</a> but didn't find the solution for my condition.</p>

<p>As this application is developed on VB so i don't have much knowledge about that.</p>

<p>How can I resolve this .</p>

<p>Please suggest</p>

<p>Thanks in advance.</p>