title: ASP.NET : How to accept Monthly, Quarterly, Semi-Annual, Anually of Period of time using Dropdown using visual basic
body: <p>Scenario. I have a dropdown list of Month(1-12) and Year (MMYYYY) format.<br>
  Start Date : Month(1-12) and Year (MMYYYY) format<br>
  End Date : Month(1-12) and Year (MMYYYY) format</p>
  
  <p>If I would select the START DATE : 10/2018 (then the start date is valid) start date should not be more than 5 years based on the current year Then the "END DATE" should be End DATE : 10/2018 ( this is valid) End date should not be more than 5 years from the start date.</p>
  
  <p>Question:</p>
  
  <ul>
  <li><p>How can I validate MonthSTART DATE : 10/2018 </p>
  
  <ul>
  <li>END DATE : 10/2018</li>
  </ul></li>
  <li><p>How can I validate Quarterly </p>
  
  <ul>
  <li>START DATE : 01/2018 </li>
  <li>END DATE : 03/2018.</li>
  <li>Quarterly are (Jan to Mar, Apr to Jun, July to Sep, Oct to Dec)</li>
  </ul></li>
  <li><p>How can I validate Semi-annual </p>
  
  <ul>
  <li>START DATE : 01/2018 </li>
  <li>END DATE : 06/2018      </li>
  <li>SEMI - ANNUAL ARE ( JAN TO JUN, JULY TO DECEMBER)</li>
  </ul></li>
  <li><p>How can I validate Annual</p>
  
  <ul>
  <li>START DATE: 01/2018 </li>
  <li>END DATE: 12/2018</li>
  </ul></li>
  </ul>
  
  <p>The above question will match my explanation below</p>
  
  <ol>
  <li><p>Monthly - whenever the user choose the start date (should not be more than 5 years from the current date) </p>
  
  <ul>
  <li>example START DATE : 10/2016 end date should be END DATE : 10/2016.   <strong>valid</strong></li>
  </ul></li>
  <li><p>QUARTERLY- 3 months. if the user will input START DATE : 10/2016 the end should be END DATE : 10/2016 <strong>valid</strong></p></li>
  <li><p>SEMI ANNUAL - 6 MONTHS if the user will input START DATE : 10/2016 the end should be END DATE : 03/2016 <strong>valid</strong></p></li>
  <li><p>ANNUAL - 12 MONTHS if the user will input START DATE : 01/2016 the end should be END DATE : 12/2016 <strong>valid</strong></p></li>
  <li><p>else
  <strong>INVALID</strong></p></li>
  </ol>
  
  <p>Output: <strong>valid</strong> or <strong>invalid</strong></p>
  
  <p>Kindly see the code below</p>
  
  <pre><code>Dim dateStart As Date=New Date(ddl_dateStartYear.SelectedValue,ddl_dateStartMonth.SelectedValue, 1)
  Dim dateEnd As Date = New Date(ddl_dateEndYear.SelectedValue, ddl_dateEndMonth.SelectedValue, 1)
  ' Today check
  If dateEnd &gt; DateTime.Now.AddYears(5) Then
      ' Invalid
  End If
  ' Five year check
  If dateStart.AddYears(5) &gt; dateEnd Then
      ' Invalid
  End If
  </code></pre>