title: C# Compare Months
body: <p>I am trying to check if the selected month is already past.</p>
  
  <pre><code>if (Convert.ToDateTime(DDMonths.SelectedItem.Text).Month &gt; DateTime.Now.Month)
  {
        //logic here if date is not in the past
  }
  </code></pre>
  
  <p><code>DDMonths.SelectedItem.Text</code> value is <code>April</code> </p>
  
  <p>However I am getting the following Format exception error:</p>
  
  <blockquote>
    <p><em>String was not recognized as a valid DateTime.</em></p>
  </blockquote>